mirror of
https://github.com/apple/container.git
synced 2026-09-11 10:15:38 +00:00
Add comments clarifying thread-safety (#282)
This commit is contained in:
@@ -45,6 +45,7 @@ public struct ContainerManager: Sendable {
|
||||
@available(macOS 26.0, *)
|
||||
public struct VmnetNetwork: Network {
|
||||
private var allocator: Allocator
|
||||
// `reference` isn't used concurrently.
|
||||
nonisolated(unsafe) private let reference: vmnet_network_ref
|
||||
|
||||
/// The IPv4 subnet of this network.
|
||||
@@ -94,6 +95,7 @@ public struct ContainerManager: Sendable {
|
||||
public let gateway: String?
|
||||
public let macAddress: String?
|
||||
|
||||
// `reference` isn't used concurrently.
|
||||
nonisolated(unsafe) private let reference: vmnet_network_ref
|
||||
|
||||
public init(
|
||||
@@ -478,9 +480,4 @@ extension CIDRAddress {
|
||||
}
|
||||
}
|
||||
|
||||
@available(macOS 26.0, *)
|
||||
private struct SendableReference: Sendable {
|
||||
nonisolated(unsafe) private let reference: vmnet_network_ref
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -31,6 +31,7 @@ public final class NATNetworkInterface: Interface, Sendable {
|
||||
public let macAddress: String?
|
||||
|
||||
@available(macOS 26, *)
|
||||
// `reference` isn't used concurrently.
|
||||
public nonisolated(unsafe) let reference: vmnet_network_ref!
|
||||
|
||||
@available(macOS 26, *)
|
||||
|
||||
@@ -267,6 +267,7 @@ extension SocketRelay {
|
||||
)
|
||||
}
|
||||
|
||||
// `buf1` isn't used concurrently.
|
||||
nonisolated(unsafe) let buf1 = UnsafeMutableBufferPointer<UInt8>.allocate(capacity: Int(getpagesize()))
|
||||
connSource.setEventHandler {
|
||||
Self.fdCopyHandler(
|
||||
@@ -278,6 +279,7 @@ extension SocketRelay {
|
||||
}
|
||||
|
||||
nonisolated(unsafe) let buf2 = UnsafeMutableBufferPointer<UInt8>.allocate(capacity: Int(getpagesize()))
|
||||
// `buf2` isn't used concurrently.
|
||||
vsockConnectionSource.setEventHandler {
|
||||
Self.fdCopyHandler(
|
||||
buffer: buf2,
|
||||
|
||||
@@ -68,6 +68,7 @@ struct VZVirtualMachineInstance: VirtualMachineInstance, Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
// `vm` isn't used concurrently.
|
||||
private nonisolated(unsafe) let vm: VZVirtualMachine
|
||||
private let queue: DispatchQueue
|
||||
private let group: MultiThreadedEventLoopGroup
|
||||
|
||||
@@ -53,6 +53,7 @@ public final class AsyncSignalHandler: Sendable {
|
||||
|
||||
struct State: Sendable {
|
||||
var conts: [AsyncStream<Int32>.Continuation] = []
|
||||
// `sources` isn't used concurrently.
|
||||
nonisolated(unsafe) var sources: [any DispatchSourceSignal] = []
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ extension IntegrationSuite {
|
||||
}
|
||||
|
||||
final class BufferWriter: Writer {
|
||||
// `data` isn't used concurrently.
|
||||
nonisolated(unsafe) var data = Data()
|
||||
|
||||
func write(_ data: Data) throws {
|
||||
|
||||
Reference in New Issue
Block a user