     /// Create a normal instance.
     public init() {}
 
+    private func withLock<Return>(timeout timeout: Timeout, @noescape body: () throws -> Return) rethrows -> Return? {
+        guard dispatch_semaphore_wait(semaphore, timeout.rawValue) == 0 else { return nil }
+        defer {
+            dispatch_semaphore_signal(semaphore)
+        }
+        return try body()
+
+    }
+
     /// Call `body` with a lock.
     /// - parameter body: A function that reads a value while locked.
     /// - returns: The value returned from the given function.
     public func withReadLock<Return>(@noescape body: () throws -> Return) rethrows -> Return {
-        dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER)
-        defer {
-            dispatch_semaphore_signal(semaphore)
-        }
-        return try body()
+        return try withLock(timeout: .Forever, body: body)!
+    }
+
+    /// Attempt to call `body` with a lock.
+    /// - returns: The value returned from `body`, or `nil` if already locked.
+    /// - seealso: withReadLock(_:)
+    public func withAttemptedReadLock<Return>(@noescape body: () throws -> Return) rethrows -> Return? {
+        return try withLock(timeout: .Now, body: body)
     }
 }
 

    /// - returns: The value returned from the given function.
    func withReadLock<Return>(@noescape body: () throws -> Return) rethrows -> Return

    /// Call `body` with a writing lock.
    ///
    /// If the implementing type models a readers-writer lock, this function may

    /// - returns: The value returned from the given function.
    public func withReadLock<Return>(@noescape body: () throws -> Return) rethrows -> Return {
        OSSpinLockLock(lock)
        defer {
            OSSpinLockUnlock(lock)
        }
        return try body()
    }

    /// Attempt to call `body` with a lock.
    /// - returns: The value returned from `body`, or `nil` if already locked.
    /// - seealso: withReadLock(_:)
    public func withAttemptedReadLock<Return>(@noescape body: () throws -> Return) rethrows -> Return? {
        guard OSSpinLockTry(lock) else { return nil }
        defer {
            OSSpinLockUnlock(lock)
        }
