   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

  {
    pthread_mutex_lock(channelMutex)

//    log("attempting to read from buffered channel")

    while self.isEmpty && !self.closed
    { // block while the channel is empty
      pthread_cond_wait(readCondition, channelMutex)
    }

    let oldElement = readElement()

    // Channel is not full; signal this.
    pthread_cond_signal(writeCondition)
    if self.closed { pthread_cond_signal(readCondition) }
    pthread_mutex_unlock(channelMutex)

//    log("read from buffered channel")

    return oldElement
  }

        }
      }

      if self.blockedReaders > 0
      { // If other readers are waiting, signal a writer right away.
        if self.blockedWriters > 0 { pthread_cond_signal(self.writeCondition) }
        // If channel is closed, then signal a reader too.
        if self.isClosed { pthread_cond_signal(self.readCondition) }
      }
      pthread_mutex_unlock(self.channelMutex)
    }

    return {
      if self.blockedReaders > 0
      {
        pthread_mutex_lock(self.channelMutex)
        pthread_cond_broadcast(self.readCondition)
        pthread_mutex_unlock(self.channelMutex)
      }
    }
  }
}

// Used to elucidate/troubleshoot message arrival order
private var readerCount = 0
