Skip to content

Instantly share code, notes, and snippets.

@alejoberman
alejoberman / locking.swift
Created May 19, 2017 08:27 — forked from einsteinx2/locking.swift
Simple synchronization functions for Swift, wrapping the Cocoa NSLocking classes
import Foundation
/// Protocol for NSLocking objects that also provide try()
public protocol TryLockable: NSLocking {
func `try`() -> Bool
}
// These Cocoa classes have tryLock()
extension NSLock: TryLockable {}
extension NSRecursiveLock: TryLockable {}

Keybase proof

I hereby claim:

  • I am alejoberman on github.
  • I am alejoberman (https://keybase.io/alejoberman) on keybase.
  • I have a public key ASAsrpTIeJEsImMqe9EfhUS2KGCMO_El_8jO3Pg_TAfttQo

To claim this, I am signing this object: