 import Dispatch
 
 /**
-  An evocative name for a closure type sent back by a selectReceive() method.
-  Upon being run, a Signal should try to resume the thread spawned by selectReceive()
+  An evocative name for a closure type sent back by a selectNotify() method.
+  Upon being run, a Signal should try to resume the thread spawned by selectNotify()
   if said thread happens to be blocked.
 
-  This attempt may not always be successful, but if such cases the thread should
+  This attempt may not always be directly successful, but in such cases the thread should
   eventually be resumed, because there would be several threads contending for the channel.
   There are situations where the Signal could be the only hope to resume the thread,
-  because it is the only one waiting on its channel. In those cases the attempt should
+  because it is the only one waiting on its channel. In all such cases the attempt must
   unblock the thread successfully.
 */
 
 public typealias Signal = () -> ()
+
+/**
+  A useful fake pointer for use with dispatch_set_context() in Signal closures.
+*/
+
 public let abortSelect = UnsafeMutablePointer<Void>(bitPattern: 1)
 
 /**

//  func insert(item: Selection) -> Bool
}

/**
  A special kind of SingletonChan for use by Select.
  SelectChan provides a way for a receiving channel to communicate back in a thread-safe
  way by using the selectSend() method within a closure passed to selectMutex().

  This would be better as an internal type.
*/

//public class SelectChan<T>: SingletonChan<T>, SelectingChannel
//{
//  typealias SentElement = T
//
//  override init()
//  {
//    super.init()
//  }
//}

/**
  Some extra interface for SelectChan.
  These methods have to be defined alongside the internals of SelectChan's superclass(es)
*/

//public protocol SelectingChannel
//{
//  typealias SentElement
//
//  /**
//    selectMutex() must be used to send data to SelectChan in a thread-safe manner
//
//    Actions which must be performed synchronously with the SelectChan should be passed to
//    selectMutex() as a closure. The closure will only be executed if the channel is still open.
//  */
//
//  func selectMutex(action: () -> ())
//
//  /**
//    selectSend() will send data to a SelectChan.
//    It must be called within the closure sent to selectMutex() for thread safety.
//    By definition, this call occurs while the channel's mutex is locked for the current thread.
//  */
//
//  func selectSend(newElement: SentElement)
//}

/**
  You can put anything in a Selection.
  It has a convenient, non-generic type.
  And it has a decidedly generic accessor method.
*/

public class Selection

  func selectNotify(semaphore: SingletonChan<dispatch_semaphore_t>, selectionID: Selectable) -> Signal

  /**
    If it makes no sense to invoke the selectNotify() method at this time, return false.
    If every Selectable in the list returns false, Select will stop by returning nil.
  */

  var selectable: Bool { get }
}

protocol SelectableChannelType: ChannelType
{
