 
         return try body()
     }
+
+    /// Attempt to call `body` with a lock.
+    ///
+    /// `body` may be called concurrently with reads on other threads.
+    ///
+    /// - returns: The value returned from `body`, or `nil` if already locked.
+    /// - seealso: withReadLock(_:)
+    public func withAttemptedReadLock<Return>(@noescape body: () throws -> Return) rethrows -> Return? {
+        // active writer
+        guard (state.memory & Constants.WriterMask) == 0 else { return nil }
+
+        // increment the reader count
+        guard (OSAtomicIncrement32Barrier(state) & Constants.WriterMask) == 0 else { return nil }
+
+        defer {
+            // decrement readers, potentially unblock writers
+            OSAtomicDecrement32Barrier(state)
+        }
+
+        return try body()
+    }
 }
 
 /// A readers-writer lock provided by the platform implementation of the

    /// - 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.
    ///
    /// `body` may be called concurrently with reads on other threads.
    ///
    /// - returns: The value returned from `body`, or `nil` if already locked.
    /// - seealso: withReadLock(_:)
    public func withAttemptedReadLock<Return>(@noescape body: () throws -> Return) rethrows -> Return? {
        guard pthread_rwlock_tryrdlock(lock) == 0 else { return nil }
        defer {
            pthread_rwlock_unlock(lock)
        }
        return try body()
    }

    /// Call `body` with a writing lock.
    ///
    /// The given function is guaranteed to be called exclusively.
