   override var capacity: Int { return 0 }
 
   private let logging = false
-  private func log(message: String) -> ()
-  {
-    if logging { syncprint(message) }
-  }
+  private func log<PT>(object: PT) -> ()
+  {
+    if logging { syncprint(object) }
+  }
+
+  /**
+    Tell whether the channel is ready to transfer data.
+
+    An unbuffered channel should always look empty to an external observer.
+    What is relevant internally is whether the data "is ready" to be transferred to a receiver.
+
+    :return: whether the data is ready for a receive operation.
+  */
+
+  var isReady: Bool { return (element != nil) }
 
   /**
     Close the channel

  // Instance variables

  private var closed = false

  private var channelMutex:   UnsafeMutablePointer<pthread_mutex_t>
  private var readCondition:  UnsafeMutablePointer<pthread_cond_t>

  {
    pthread_mutex_lock(channelMutex)

    let id = readerCount++
//    log("reader \(id) is trying to receive")

    while self.isEmpty && !self.isClosed
    { // block while the channel is empty
      blockedReaders += 1
      pthread_cond_wait(readCondition, channelMutex)
      blockedReaders -= 1
    }

    let oldElement = readElement()

    // Channel is not full; signal this.
    if blockedWriters > 0 { pthread_cond_signal(writeCondition) }
    if self.isClosed && blockedReaders > 0 { pthread_cond_signal(readCondition) }
    pthread_mutex_unlock(channelMutex)

//    log("reader \(id) received \(oldElement)")

    return oldElement
  }
