         #endif
         
         override init() {
-            ownRunLoop = true
             var runLoop:CFRunLoop?
             let cond = NSCondition()
             cond.lock()

            pthread_create(thread, nil, thread_proc, UnsafeMutablePointer<Void>(Unmanaged.passRetained(self).toOpaque()))
        }
    }

    private func sourceMain(rls: UnsafeMutablePointer<Void>) {
        let runLoopSource = Unmanaged<RunLoopSource>.fromOpaque(COpaquePointer(rls)).takeUnretainedValue()
        runLoopSource.cfSource = nil
        runLoopSource.task()
    }

    private func sourceCancel(rls: UnsafeMutablePointer<Void>, rL: CFRunLoop!, mode:CFString!) {
        let runLoopSource = Unmanaged<RunLoopSource>.fromOpaque(COpaquePointer(rls)).takeUnretainedValue()
        runLoopSource.cfSource = nil
    }

    private func sourceRetain(rls: UnsafePointer<Void>) -> UnsafePointer<Void> {
        Unmanaged<RunLoopSource>.fromOpaque(COpaquePointer(rls)).retain()
        return rls
    }

    private func sourceRelease(rls: UnsafePointer<Void>) {
        Unmanaged<RunLoopSource>.fromOpaque(COpaquePointer(rls)).release()
    }

    private class RunLoopSource {
        private var cfSource:CFRunLoopSource? = nil
        private let task:SafeTask
        private let priority:Int

        init(_ task: SafeTask, priority: Int = 0) {
            self.task = task
            self.priority = priority
        }

        deinit {
            if let s = cfSource {
                if CFRunLoopSourceIsValid(s) { CFRunLoopSourceInvalidate(s) }
            }
        }

        func addToRunLoop(runLoop:CFRunLoop, mode: CFString) {
            if cfSource == nil {
                var context = CFRunLoopSourceContext(
                    version: 0,
                    info: UnsafeMutablePointer<Void>(Unmanaged.passUnretained(self).toOpaque()),
                    retain: sourceRetain,
                    release: sourceRelease,
                    copyDescription: nil,
                    equal: nil,
                    hash: nil,
                    schedule: nil,
                    cancel: sourceCancel,
                    perform: sourceMain
                )
                self.cfSource = CFRunLoopSourceCreate(nil, priority, &context)
            }
            
            CFRunLoopAddSource(runLoop, cfSource!, mode)
        }

        func signal() {
            if let s = cfSource {
                CFRunLoopSourceSignal(s)
            }
        }
    }
    

            return try inner.sync(task)
        }
        
        public func async(after:Double, task:SafeTask) {
            inner.async(after, task: task)
        }
        
        public static let main:ExecutionContextType = PThreadExecutionContext(inner: SerialContext(runLoop: CFRunLoopGetMain()))
        public static let global:ExecutionContextType = PThreadExecutionContext(kind: .Parallel)
    }
