Luky Library - 4.1.1 (20061117-1148)

luky.util
Class BinarySemaphore

java.lang.Object
  extended by luky.util.BinarySemaphore

public class BinarySemaphore
extends Object

The BinarySempaphore Class is a class that holds all logic that's required for synchronizing access and execution of threads

Version:
1.00
Author:
Chris Lukassen
 

Constructor Summary
BinarySemaphore()
          constructor for a blocking semaphore (no timeout)
BinarySemaphore(long timeout)
          timed constructor
BinarySemaphore(String timeout)
          timed constructor
 
Method Summary
 int getSem()
          takes the current semaphore, in case the semaphore is not available the method will 'hang' until a semaphore is set or a timeout occurs
 long getTimeoutValue()
          returns the timeout value for this semaphore
 int setSem()
          sets the current semaphore, in case a different thread was 'hanging' on this thread will be released
 int setTimeoutValue(long timeout)
          sets the timeout value for this semaphore, blocked threads will not be affected
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinarySemaphore

public BinarySemaphore()
constructor for a blocking semaphore (no timeout)


BinarySemaphore

public BinarySemaphore(long timeout)
timed constructor

Parameters:
timeout - long value specifying the timeout value in milli seconds

BinarySemaphore

public BinarySemaphore(String timeout)
timed constructor

Parameters:
timeout - string value specifying the timeout value in milli seconds
Method Detail

setTimeoutValue

public int setTimeoutValue(long timeout)
sets the timeout value for this semaphore, blocked threads will not be affected

Parameters:
timeout - long value specifying the timeout value in milli seconds
Returns:
Constants.NOK in case the timeout value is illegal or Constants.OK in case the value was accepted

getTimeoutValue

public long getTimeoutValue()
returns the timeout value for this semaphore

Returns:
the current timeout value

getSem

public int getSem()
takes the current semaphore, in case the semaphore is not available the method will 'hang' until a semaphore is set or a timeout occurs

Returns:
Constants.NOK in case an the wait method was interupted, Constants.OK in case the semaphore has been taken succesfully or Constants.TIMEOUT in case a timeout has occured

setSem

public int setSem()
sets the current semaphore, in case a different thread was 'hanging' on this thread will be released

Returns:
Constants.NOK in case the semaphore had already been set, Constants.OK if all went well

Luky Library - 4.1.1 (20061117-1148)