Skip to content

Commit

Permalink
some linux fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bsneed committed May 9, 2024
1 parent 7b19f1b commit 75a238f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/Segment/Utilities/Atomic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Foundation
@propertyWrapper
public class Atomic<T> {
#if os(Linux)
let lock: NSLock
let swiftLock: NSLock
#else
internal typealias os_unfair_lock_t = UnsafeMutablePointer<os_unfair_lock_s>
internal var unfairLock: os_unfair_lock_t
Expand All @@ -33,7 +33,7 @@ public class Atomic<T> {

public init(wrappedValue value: T) {
#if os(Linux)
self.lock = NSLock()
self.swiftLock = NSLock()
#else
self.unfairLock = UnsafeMutablePointer<os_unfair_lock_s>.allocate(capacity: 1)
self.unfairLock.initialize(to: os_unfair_lock())
Expand Down Expand Up @@ -70,15 +70,15 @@ public class Atomic<T> {
extension Atomic {
internal func lock() {
#if os(Linux)
self.lock.lock()
swiftLock.lock()
#else
os_unfair_lock_lock(unfairLock)
#endif
}

internal func unlock() {
#if os(Linux)
self.lock.unlock()
swiftLock.unlock()
#else
os_unfair_lock_unlock(unfairLock)
#endif
Expand Down

0 comments on commit 75a238f

Please sign in to comment.