 
   deinit
   {
-    let kr = semaphore_destroy(mach_task_self_, semp)
-    assert(kr == KERN_SUCCESS, __FUNCTION__)
+    if semp != 0
+    {
+      let kr = semaphore_destroy(mach_task_self_, semp)
+      assert(kr == KERN_SUCCESS, __FUNCTION__)
+    }
   }
 
   final private func initSemaphorePort()

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

    case .Done:
      currentState = ChannelSemaphoreState.Done.rawValue
      OSMemoryBarrier()
      return true

    default:

//  Copyright (c) 2015 Guillaume Lessard. All rights reserved.
//

import Darwin.Mach.task
import Darwin.Mach.semaphore
import Darwin.Mach.mach_time
import Darwin.libkern.OSAtomic
import Dispatch.time
import Foundation.NSThread

