mirror of
https://github.com/GLEGram/GLEGram-iOS.git
synced 2026-04-24 20:06:39 +02:00
4647310322
Based on Swiftgram 12.5 (Telegram iOS 12.5). All GLEGram features ported and organized in GLEGram/ folder. Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass, Font Replacement, Fake Profile, Chat Export, Plugin System, and more. See CHANGELOG_12.5.md for full details.
59 lines
1.5 KiB
Swift
59 lines
1.5 KiB
Swift
//// A copy of Atomic from SwiftSignalKit
|
|
//import Foundation
|
|
//
|
|
//public enum AtomicWrapperLockError: Error {
|
|
// case isLocked
|
|
//}
|
|
//
|
|
//public final class AtomicWrapper<T> {
|
|
// private var lock: pthread_mutex_t
|
|
// private var value: T
|
|
//
|
|
// public init(value: T) {
|
|
// self.lock = pthread_mutex_t()
|
|
// self.value = value
|
|
//
|
|
// pthread_mutex_init(&self.lock, nil)
|
|
// }
|
|
//
|
|
// deinit {
|
|
// pthread_mutex_destroy(&self.lock)
|
|
// }
|
|
//
|
|
// public func with<R>(_ f: (T) -> R) -> R {
|
|
// pthread_mutex_lock(&self.lock)
|
|
// let result = f(self.value)
|
|
// pthread_mutex_unlock(&self.lock)
|
|
//
|
|
// return result
|
|
// }
|
|
//
|
|
// public func tryWith<R>(_ f: (T) -> R) throws -> R {
|
|
// if pthread_mutex_trylock(&self.lock) == 0 {
|
|
// let result = f(self.value)
|
|
// pthread_mutex_unlock(&self.lock)
|
|
// return result
|
|
// } else {
|
|
// throw AtomicWrapperLockError.isLocked
|
|
// }
|
|
// }
|
|
//
|
|
// public func modify(_ f: (T) -> T) -> T {
|
|
// pthread_mutex_lock(&self.lock)
|
|
// let result = f(self.value)
|
|
// self.value = result
|
|
// pthread_mutex_unlock(&self.lock)
|
|
//
|
|
// return result
|
|
// }
|
|
//
|
|
// public func swap(_ value: T) -> T {
|
|
// pthread_mutex_lock(&self.lock)
|
|
// let previous = self.value
|
|
// self.value = value
|
|
// pthread_mutex_unlock(&self.lock)
|
|
//
|
|
// return previous
|
|
// }
|
|
//}
|