 		return map({ transform($0).value })
 	}
 }
+
+// MARK: -
+
+private enum _Lock {
+	case synchronous(Lock)
+	case concurrent(ConcurrentLock)
+	var lock: Lock {
+		switch self {
+		case .synchronous(let lock): return lock
+		case .concurrent(let lock): return lock
+		}
+	}
+}

public final class Synchronized<Wrapped> {
	// MARK: Private implementation
	
	private var _lock: Lock
	private var _value: Wrapped

	private func readSync <T> (_ perform: () throws -> T) rethrows -> T {
		guard let concurrentLock = _lock as? ConcurrentLock else {
			return try _lock.sync(perform)
		}
		return try concurrentLock.concurrentSync(perform)
	}

	fileprivate var _allowConcurrentReads: Bool {

	///		to the wrapped value.
	/// - parameter value: The current wrapped value. Can be updated directly.
	public func atomicallyUpdate(_ update: (_ value: inout Wrapped) throws -> Void) rethrows {
		try _lock.lock.sync({ try update(&_value) })
	}
}

