com.sun.rtsjx
Class Semaphore

java.lang.Object
  extended by com.sun.rtsjx.Semaphore

public final class Semaphore
extends java.lang.Object

Semaphore that never block the producer.

The sema_post and sema_trywait can safely be used by NoHeapRealtimeThread. Unbounded blocks due to garbage collection or low priority concurrent users cannot happen.


Constructor Summary
Semaphore()
          Constructor.
 
Method Summary
 int sema_count()
          Get the count.
 boolean sema_post()
          Producer.
 boolean sema_trywait()
          Non blocking consumer.
 void sema_wait_interruptible()
          Blocking interruptible consumer.
 void sema_wait()
          Blocking consumer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Semaphore

public Semaphore()
Constructor.

The initial count is 0.

Method Detail

sema_wait

public final void sema_wait()
Blocking consumer.

Blocks until it atomically decreases a strictly positive count.


sema_wait_interruptible

public final void sema_wait_interruptible()
                                   throws java.lang.InterruptedException
Blocking interruptible consumer.

Blocks until it atomically decreases a strictly positive count or until the thread is interrupted.

Throws:
java.lang.InterruptedException - Thrown if the wait is interrupted.

sema_trywait

public final boolean sema_trywait()
Non blocking consumer.

Returns:
true if is sucesfully atomically decreased a strictly positive count

sema_post

public final boolean sema_post()
Producer.

Atomically increase the count by one, unless it overflows.

Returns:
false on overflow.

sema_count

public final int sema_count()
Get the count.

The value return is the count at unspecified time during the call. It may be concurrently modified.

Returns:
the count.