mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge branch 'macos-10.8-release'
# Conflicts: # submodules/Postbox/Sources/Postbox.swift
This commit is contained in:
commit
4f7a7f43a0
@ -2994,7 +2994,7 @@ final class PostboxImpl {
|
|||||||
|
|
||||||
let isInTransaction: Atomic<Bool>
|
let isInTransaction: Atomic<Bool>
|
||||||
|
|
||||||
private func internalTransaction<T>(_ f: (Transaction) -> T) -> (result: T, updatedTransactionStateVersion: Int64?, updatedMasterClientId: Int64?) {
|
private func internalTransaction<T>(_ f: (Transaction) -> T, file: String = #file, line: Int = #line) -> (result: T, updatedTransactionStateVersion: Int64?, updatedMasterClientId: Int64?) {
|
||||||
let _ = self.isInTransaction.swap(true)
|
let _ = self.isInTransaction.swap(true)
|
||||||
|
|
||||||
let startTime = CFAbsoluteTimeGetCurrent()
|
let startTime = CFAbsoluteTimeGetCurrent()
|
||||||
@ -3010,7 +3010,7 @@ final class PostboxImpl {
|
|||||||
let endTime = CFAbsoluteTimeGetCurrent()
|
let endTime = CFAbsoluteTimeGetCurrent()
|
||||||
let transactionDuration = endTime - startTime
|
let transactionDuration = endTime - startTime
|
||||||
if transactionDuration > 0.1 {
|
if transactionDuration > 0.1 {
|
||||||
postboxLog("Postbox transaction took \(transactionDuration * 1000.0) ms")
|
postboxLog("Postbox transaction took \(transactionDuration * 1000.0) ms, from: \(file), on:\(line)")
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = self.isInTransaction.swap(false)
|
let _ = self.isInTransaction.swap(false)
|
||||||
@ -3052,13 +3052,14 @@ final class PostboxImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func transaction<T>(userInteractive: Bool = false, ignoreDisabled: Bool = false, _ f: @escaping(Transaction) -> T) -> Signal<T, NoError> {
|
|
||||||
|
public func transaction<T>(userInteractive: Bool = false, ignoreDisabled: Bool = false, _ f: @escaping(Transaction) -> T, file: String = #file, line: Int = #line) -> Signal<T, NoError> {
|
||||||
return Signal { subscriber in
|
return Signal { subscriber in
|
||||||
let f: () -> Void = {
|
let f: () -> Void = {
|
||||||
self.beginInternalTransaction(ignoreDisabled: ignoreDisabled, {
|
self.beginInternalTransaction(ignoreDisabled: ignoreDisabled, {
|
||||||
let (result, updatedTransactionState, updatedMasterClientId) = self.internalTransaction({ transaction in
|
let (result, updatedTransactionState, updatedMasterClientId) = self.internalTransaction({ transaction in
|
||||||
return f(transaction)
|
return f(transaction)
|
||||||
})
|
}, file: file, line: line)
|
||||||
|
|
||||||
if updatedTransactionState != nil || updatedMasterClientId != nil {
|
if updatedTransactionState != nil || updatedMasterClientId != nil {
|
||||||
//self.pipeNotifier.notify()
|
//self.pipeNotifier.notify()
|
||||||
@ -4407,12 +4408,12 @@ public class Postbox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func transaction<T>(userInteractive: Bool = false, ignoreDisabled: Bool = false, _ f: @escaping(Transaction) -> T) -> Signal<T, NoError> {
|
public func transaction<T>(userInteractive: Bool = false, ignoreDisabled: Bool = false, _ f: @escaping(Transaction) -> T, file: String = #file, line: Int = #line) -> Signal<T, NoError> {
|
||||||
return Signal<T, NoError> { subscriber in
|
return Signal<T, NoError> { subscriber in
|
||||||
let disposable = MetaDisposable()
|
let disposable = MetaDisposable()
|
||||||
|
|
||||||
self.impl.with { impl in
|
self.impl.with { impl in
|
||||||
disposable.set(impl.transaction(userInteractive: userInteractive, ignoreDisabled: ignoreDisabled, f).start(next: subscriber.putNext, error: subscriber.putError, completed: subscriber.putCompletion))
|
disposable.set(impl.transaction(userInteractive: userInteractive, ignoreDisabled: ignoreDisabled, f, file: file, line: line).start(next: subscriber.putNext, error: subscriber.putError, completed: subscriber.putCompletion))
|
||||||
}
|
}
|
||||||
|
|
||||||
return disposable
|
return disposable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user