Skip to content

Commit 1b1cfdb

Browse files
authored
Add comments clarifying thread-safety (#282)
1 parent 9aa5525 commit 1b1cfdb

File tree

6 files changed

+8
-5
lines changed

6 files changed

+8
-5
lines changed

Sources/Containerization/ContainerManager.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public struct ContainerManager: Sendable {
4545
@available(macOS 26.0, *)
4646
public struct VmnetNetwork: Network {
4747
private var allocator: Allocator
48+
// `reference` isn't used concurrently.
4849
nonisolated(unsafe) private let reference: vmnet_network_ref
4950

5051
/// The IPv4 subnet of this network.
@@ -94,6 +95,7 @@ public struct ContainerManager: Sendable {
9495
public let gateway: String?
9596
public let macAddress: String?
9697

98+
// `reference` isn't used concurrently.
9799
nonisolated(unsafe) private let reference: vmnet_network_ref
98100

99101
public init(
@@ -478,9 +480,4 @@ extension CIDRAddress {
478480
}
479481
}
480482

481-
@available(macOS 26.0, *)
482-
private struct SendableReference: Sendable {
483-
nonisolated(unsafe) private let reference: vmnet_network_ref
484-
}
485-
486483
#endif

Sources/Containerization/NATNetworkInterface.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public final class NATNetworkInterface: Interface, Sendable {
3131
public let macAddress: String?
3232

3333
@available(macOS 26, *)
34+
// `reference` isn't used concurrently.
3435
public nonisolated(unsafe) let reference: vmnet_network_ref!
3536

3637
@available(macOS 26, *)

Sources/Containerization/UnixSocketRelay.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ extension SocketRelay {
267267
)
268268
}
269269

270+
// `buf1` isn't used concurrently.
270271
nonisolated(unsafe) let buf1 = UnsafeMutableBufferPointer<UInt8>.allocate(capacity: Int(getpagesize()))
271272
connSource.setEventHandler {
272273
Self.fdCopyHandler(
@@ -278,6 +279,7 @@ extension SocketRelay {
278279
}
279280

280281
nonisolated(unsafe) let buf2 = UnsafeMutableBufferPointer<UInt8>.allocate(capacity: Int(getpagesize()))
282+
// `buf2` isn't used concurrently.
281283
vsockConnectionSource.setEventHandler {
282284
Self.fdCopyHandler(
283285
buffer: buf2,

Sources/Containerization/VZVirtualMachineInstance.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ struct VZVirtualMachineInstance: VirtualMachineInstance, Sendable {
6868
}
6969
}
7070

71+
// `vm` isn't used concurrently.
7172
private nonisolated(unsafe) let vm: VZVirtualMachine
7273
private let queue: DispatchQueue
7374
private let group: MultiThreadedEventLoopGroup

Sources/ContainerizationOS/AsyncSignalHandler.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public final class AsyncSignalHandler: Sendable {
5353

5454
struct State: Sendable {
5555
var conts: [AsyncStream<Int32>.Continuation] = []
56+
// `sources` isn't used concurrently.
5657
nonisolated(unsafe) var sources: [any DispatchSourceSignal] = []
5758
}
5859

Sources/Integration/ProcessTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ extension IntegrationSuite {
6262
}
6363

6464
final class BufferWriter: Writer {
65+
// `data` isn't used concurrently.
6566
nonisolated(unsafe) var data = Data()
6667

6768
func write(_ data: Data) throws {

0 commit comments

Comments
 (0)