         } while true
 
         // read lock acquired - run block
-        let result = block()
+        let result = body()
 
         // decrement reader count
         do {

        return result
    }

    public func withReadLock<T>(block: () -> T) -> T {
        // spin until we acquire read lock
        do {
            let state = _state.memory

import Foundation

public protocol ReadWriteLock {
    func withReadLock<T>(@noescape body: () -> T) -> T
    func withWriteLock<T>(@noescape body: () -> T) -> T
}

public struct DispatchLock: ReadWriteLock {
