You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
291 B
15 lines
291 B
//
|
|
// Copyright © 2019 Swinject Contributors. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
internal final class SpinLock {
|
|
private let lock = NSRecursiveLock()
|
|
|
|
func sync<T>(action: () -> T) -> T {
|
|
lock.lock()
|
|
defer { lock.unlock() }
|
|
return action()
|
|
}
|
|
}
|