This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
@propertyWrapper | |
public struct ThreadSafe<T> { | |
public var lock = DispatchSemaphore(value: 1) | |
private var value: T | |
public var wrappedValue: T { | |
get { | |
lock.wait() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public protocol Observable { | |
/// Registers an Observer against this Observable Type | |
func addObserver<TObservationProtocol: AnyObject>(_ observer: TObservationProtocol) | |
/// Removes an Observer from this Observable Type | |
func removeObserver<TObservationProtocol: AnyObject>(_ observer: TObservationProtocol) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
enum MachTimerError: Error { | |
case TimebaseInfoError // Only thrown where we cannot initialize the Mach Timer (shouldn't ever happen though) | |
} | |
struct MachTimer { | |
// We need to know whether or not the Timer is still running or Stopped at the point of requesting a Result | |
enum MachTimerState { | |
case NotRunning |