mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00

git-subtree-dir: submodules/SSignalKit git-subtree-mainline: 4459dc5b47e7db4ea1adb3a43a4324d1c2f9feab git-subtree-split: 359b2ee7c9f20f99f221f78e307369ef5ad0ece2
20 lines
377 B
Swift
20 lines
377 B
Swift
import Foundation
|
|
|
|
public final class Lock {
|
|
private var mutex = pthread_mutex_t()
|
|
|
|
public init() {
|
|
pthread_mutex_init(&self.mutex, nil)
|
|
}
|
|
|
|
deinit {
|
|
pthread_mutex_destroy(&self.mutex)
|
|
}
|
|
|
|
public func locked(_ f: () -> ()) {
|
|
pthread_mutex_lock(&self.mutex)
|
|
f()
|
|
pthread_mutex_unlock(&self.mutex)
|
|
}
|
|
}
|