         about the new value.
     */
     public func update(result: Result<T>) {
-        #if os(Linux)
-        #else
-        objc_sync_enter(self)
-        defer { objc_sync_exit(self) }
-        #endif
-        self.value = result
-        self.callbacks.forEach{$0(result)}
+        lock.sync {
+            value = result
+            callbacks.forEach{$0(result)}
+        }
     }
     
     /**

        return value?.value
    }
}


*/
import Foundation
#if os(Linux)
    import Glibc
#else
    import Darwin
#endif

public final class Signal<T> {
    
    private var value: Result<T>?
    private var callbacks: [Result<T> -> Void] = []
    private let lock = Lock()
    
    /// Automatically infer the type of the signal from the argument.
    public convenience init(_ value: T){
