Skip to content

Commit 46e150c

Browse files
committed
Minor
1 parent 4945696 commit 46e150c

File tree

3 files changed

+35
-43
lines changed

3 files changed

+35
-43
lines changed

Sources/AppBundle/tree/MacApp.swift

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -388,47 +388,4 @@ private func disableAnimations<T>(app: AXUIElement, _ body: () -> T) -> T {
388388
return body()
389389
}
390390

391-
public final class ThreadGuardedValue<Value>: Sendable {
392-
private nonisolated(unsafe) var _threadGuarded: Value?
393-
private let threadToken: AxAppThreadToken = axTaskLocalAppThreadToken ?? dieT("axTaskLocalAppThreadToken is not initialized")
394-
public init(_ value: Value) { self._threadGuarded = value }
395-
var threadGuarded: Value {
396-
get {
397-
threadToken.checkEquals(axTaskLocalAppThreadToken)
398-
return _threadGuarded ?? dieT("Value is already destroyed")
399-
}
400-
set(newValue) {
401-
threadToken.checkEquals(axTaskLocalAppThreadToken)
402-
_threadGuarded = newValue
403-
}
404-
}
405-
func destroy() {
406-
threadToken.checkEquals(axTaskLocalAppThreadToken)
407-
_threadGuarded = nil
408-
}
409-
deinit {
410-
check(_threadGuarded == nil, "The Value must be explicitly destroyed on the appropriate thread before deinit")
411-
}
412-
}
413-
414-
public final class MutableUnsafeSendable<T>: Sendable {
415-
nonisolated(unsafe) var unsafe: T
416-
public init(_ value: T) { self.unsafe = value }
417-
}
418-
419-
public final class UnsafeSendable<T>: Sendable {
420-
nonisolated(unsafe) let unsafe: T
421-
public init(_ value: T) { self.unsafe = value }
422-
}
423-
424391
public typealias Continuation<T> = CheckedContinuation<T, Never>
425-
426-
extension NSRunningApplication {
427-
func isFirefox() -> Bool {
428-
["org.mozilla.firefox", "org.mozilla.firefoxdeveloperedition", "org.mozilla.nightly"].contains(bundleIdentifier ?? "")
429-
}
430-
431-
var idForDebug: String {
432-
"PID: \(processIdentifier) ID: \(bundleIdentifier ?? executableURL?.description ?? "")"
433-
}
434-
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import AppKit
2+
3+
extension NSRunningApplication {
4+
func isFirefox() -> Bool {
5+
["org.mozilla.firefox", "org.mozilla.firefoxdeveloperedition", "org.mozilla.nightly"].contains(bundleIdentifier ?? "")
6+
}
7+
8+
var idForDebug: String {
9+
"PID: \(processIdentifier) ID: \(bundleIdentifier ?? executableURL?.description ?? "")"
10+
}
11+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import Common
2+
3+
public final class ThreadGuardedValue<Value>: Sendable {
4+
private nonisolated(unsafe) var _threadGuarded: Value?
5+
private let threadToken: AxAppThreadToken = axTaskLocalAppThreadToken ?? dieT("axTaskLocalAppThreadToken is not initialized")
6+
public init(_ value: Value) { self._threadGuarded = value }
7+
var threadGuarded: Value {
8+
get {
9+
threadToken.checkEquals(axTaskLocalAppThreadToken)
10+
return _threadGuarded ?? dieT("Value is already destroyed")
11+
}
12+
set(newValue) {
13+
threadToken.checkEquals(axTaskLocalAppThreadToken)
14+
_threadGuarded = newValue
15+
}
16+
}
17+
func destroy() {
18+
threadToken.checkEquals(axTaskLocalAppThreadToken)
19+
_threadGuarded = nil
20+
}
21+
deinit {
22+
check(_threadGuarded == nil, "The Value must be explicitly destroyed on the appropriate thread before deinit")
23+
}
24+
}

0 commit comments

Comments
 (0)