 //  Copyright (c) 2015 Guillaume Lessard. All rights reserved.
 //
 
-import Darwin.Mach
+import Darwin.Mach.task
+import Darwin.Mach.semaphore
+import Darwin.Mach.mach_time
+import Darwin.libkern.OSAtomic
 import Dispatch.time
 import Foundation.NSThread
 


// MARK: ChannelSemaphore

final public class ChannelSemaphore
{
  private var svalue: Int32

      return OSAtomicCompareAndSwap32Barrier(ChannelSemaphoreState.Ready.rawValue, newState.rawValue, &currentState)

    case .Done:
      // Ideally it would be: __sync_swap(&currentState, ChannelSemaphoreState.Done.rawValue)
      while OSAtomicCompareAndSwap32Barrier(currentState, ChannelSemaphoreState.Done.rawValue, &currentState) == false {}
      return true

    default:
