         return CancellationToken(source: self)
     }
 
-    private var _observers: ContiguousArray<() -> Void>? = []
+    private var lock = NSLock()
+    private var observers: [() -> Void]? = []
 
     /// Initializes the `CancellationTokenSource` instance.
     init() {}

internal final class CancellationTokenSource {
    /// Returns `true` if cancellation has been requested.
    var isCancelling: Bool {
        return _lock.sync { _observers == nil }
    }

    /// Creates a new token associated with the source.

        }
    }

    private func _cancel() -> [() -> Void]? {
        lock.lock()
        defer { lock.unlock() }

        let observers = self.observers
        self.observers = nil // transition to `isCancelling` state
        return observers
    }
}

/// Enables cooperative cancellation of operations.
///
