     { // 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)
+      let pointer = UnsafeMutablePointer<T>(dispatch_get_context(rs))
+      if pointer == UnsafeMutablePointer.null()
+      { // not a normal code path.
+        dispatch_semaphore_signal(nil)
+        return false
+      }
       pointer.initialize(newElement)
-      dispatch_set_context(rs, pointer)
       dispatch_semaphore_signal(rs)
       return true
     }

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

    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
