     }
     
     // Called from generator thread to get next yielded value
-    func next() -> T? {
+    private func next() -> T? {
         if !_isBackgroundTaskRunning {
             dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
                 self.run()

    }
    
    // Called from background thread to yield nil from next()
    func _yieldNil() {
        dispatch_semaphore_wait(_semValueDesired, DISPATCH_TIME_FOREVER)
        dispatch_sync(_syncQueue) {
            self._lastYieldedValue = Array<T>()



// Create a sequence from a closure that invokes a "yield" function
public func sequence<T>(yielder: ((T) -> ()) -> ()) -> SequenceOf<T> {
    return SequenceOf<T>({YieldGenerator(yielder)})
}

