biz.onixs.fix.engine.util
Class Semaphore

java.lang.Object
  extended by biz.onixs.fix.engine.util.Semaphore

public class Semaphore
extends Object

Implementation of Dijkstra's counting semaphore in java.


Constructor Summary
Semaphore(int count)
          Create a Semaphore.
 
Method Summary
 void acquire()
          Acquire the Semaphore.
 void acquire(long timeOut)
          Acquire the Semaphore.
 void release()
          Release the Semaphore.
 boolean tryAcquire(long timeOut)
          Acquire the Semaphore.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Semaphore

public Semaphore(int count)
Create a Semaphore.

Parameters:
count - semaphore count
Method Detail

acquire

public void acquire()
             throws InterruptedException
Acquire the Semaphore. Note that this will block.

Throws:
InterruptedException - exception during wait

acquire

public void acquire(long timeOut)
             throws TimeoutException,
                    InterruptedException
Acquire the Semaphore. Note that the call will return if amount of time expires.

Parameters:
timeOut - amount of time (millisec) to wait before returning (unless operation completes before)
Throws:
TimeoutException - wait timed out exception
InterruptedException - exception during wait

tryAcquire

public boolean tryAcquire(long timeOut)
                   throws InterruptedException
Acquire the Semaphore. Note that the call will return if amount of time expires.

Parameters:
timeOut - amount of time (millisec) to wait before returning (unless operation completes before)
Throws:
InterruptedException - exception during wait

release

public void release()
Release the Semaphore.



Copyright © 2005-2012 Onix Solutions. All Rights Reserved.