Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132import Synchronization
package struct AppThreadOperationInvalidated: Error, Equatable {}
package final class AppThreadOperationValidity: Sendable, Equatable { package static func == (lhs: AppThreadOperationValidity, rhs: AppThreadOperationValidity) -> Bool { lhs === rhs }
private let valid = Mutex(true) private let parent: AppThreadOperationValidity?
package init(parent: AppThreadOperationValidity? = nil) { self.parent = parent }
package var isValid: Bool { valid.withLock { $0 } && parent?.isValid != false }
package func invalidate() { valid.withLock { $0 = false } }
package func check() throws { guard isValid else { throw AppThreadOperationInvalidated() } }
package func perform<Window, Value>( resolve: () throws -> Window, operation: (Window) throws -> Value ) throws -> Value { try check() let window = try resolve() try check() return try operation(window) }}