     // Unblock the threads waiting on our conditions.
     if readerQueue.count > 0
     {
-      while let rs = readerQueue.dequeue() { dispatch_semaphore_signal(rs) }
+      while let rs = readerQueue.dequeue()
+      {
+        dispatch_set_context(rs, nil)
+        dispatch_semaphore_signal(rs)
+      }
     }
     if writerQueue.count > 0
     {

    { // there is already an interested reader
      OSSpinLockUnlock(&mutex)
      // attach a new copy of our data to the reader's semaphore
      let pointer = UnsafeMutablePointer<T>.alloc(1)
      pointer.initialize(newElement)
      dispatch_set_context(rs, pointer)
      dispatch_semaphore_signal(rs)
      return true
    }

    let context = UnsafeMutablePointer<T>(dispatch_get_context(threadLock))
    if context == UnsafeMutablePointer.null()
    { // thread was awoken by a close(), not a writer
      pointer.dealloc(1)
      SemaphorePool.enqueue(threadLock)
      return nil
    }

    assert(context == pointer)

    let element = pointer.move()
    pointer.dealloc(1)
    dispatch_set_context(threadLock, nil)
    SemaphorePool.enqueue(threadLock)
    return element
