mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Residual coding
This commit is contained in:
@@ -16,4 +16,19 @@ public final class Lock {
|
||||
f()
|
||||
pthread_mutex_unlock(&self.mutex)
|
||||
}
|
||||
|
||||
public func throwingLocked(_ f: () throws -> Void) throws {
|
||||
var error: Error?
|
||||
pthread_mutex_lock(&self.mutex)
|
||||
do {
|
||||
try f()
|
||||
} catch let e {
|
||||
error = e
|
||||
}
|
||||
pthread_mutex_unlock(&self.mutex)
|
||||
|
||||
if let error = error {
|
||||
throw(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user