Skip to content

Commit

Permalink
Merge branch 'bsneed/more_stress' of github.com:segmentio/analytics-s…
Browse files Browse the repository at this point in the history
…wift into bsneed/more_stress
  • Loading branch information
bsneed committed May 9, 2024
2 parents e216a7b + 75a238f commit 145a578
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 145a578

Please sign in to comment.