 final public class SemaphoreChan: ChannelType
 {
   private let semaphore: dispatch_semaphore_t
-
-  // housekeeping variables
-
-  private var readerCount: Int32 = 0
+  private var lock: Int32 = 0
 
   public init(_ newElement: dispatch_semaphore_t)
   {


  public func get() -> dispatch_semaphore_t?
  {
    if readerCount < 1
    {
      let reader = OSAtomicIncrement32Barrier(&readerCount)
      if reader == 1
      {
        return semaphore
      }
    }
    // if this is not the first reader, too late.
    return nil
  }

//
//  semaphore-chan.swift
//  concurrency
//
//  Created by Guillaume Lessard on 2015-02-11.
//  Copyright (c) 2014 Guillaume Lessard. All rights reserved.
//

