         self.value = value
         signals = Array()
         lock = NSLock()
+        signaled = try! ThreadLocal()
     }
     
     //TODO: optimise with atomics for value. Will allow to run non-blocked sema faster

                task()
                loop.stop()
            }
        case .Sema(let sema):
            task()
            sema.signal()
        }
    }
}

public class RunLoopSemaphore : SemaphoreType {
    private var signals:[HashableAnyContainer<SafeTask>]
    private let lock:NSLock
    private var value:Int
    
    public required convenience init() {
        self.init(value: 0)

        let loop = RunLoop.current
        let wakeable:Wakeable = Wakeable(loop: loop)
        
        let signal = {
            wakeable.wake {
                self.signaled.value = true
            }
        }
        
