         var object: T!
         dispatch_sync(queue) {
             object = block()
-        }
-        return object
-    }
-
-    mutating func read<T>(block: () throws -> T) rethrows -> T {
-        var object: T!
-        try dispatch_sync(queue) {
-            object = try block()
         }
         return object
     }

        })
    }
}

public func dispatch_sync(queue: dispatch_queue_t, _ block: () throws -> Void) rethrows {
    var failure: ErrorType? = .None

    let catcher = {
        do {
            try block()
        }
        catch {
            failure = error
        }
    }

    dispatch_sync(queue, catcher)

    if let failure = failure {
        try { throw failure }()
    }
}

public func dispatch_sync<T>(queue: dispatch_queue_t, _ block: () throws -> T) rethrows -> T {
    var result: T!
    try dispatch_sync(queue) {
        result = try block()
    }
    return result
}

        return lock.read { [unowned self] in block(self.ward) }
    }

    func write(block: (inout T) -> Void) {
        lock.write({ block(&self.ward) })
    }
