|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.wpi.first.wpilibj.communication.Semaphore
public class Semaphore
Emulates various VXWorks semaphores using Java native methods. Note: The options passed in currently are completely ignored.
Nested Class Summary | |
---|---|
static class |
Semaphore.Options
Options to create a semaphore with. |
Field Summary | |
---|---|
static int |
WAIT_FOREVER
|
Constructor Summary | |
---|---|
Semaphore(Semaphore.Options options)
Create a new mutex semaphore. |
|
Semaphore(Semaphore.Options options,
boolean initialState)
Create a boolean semaphore with the given initial state. |
|
Semaphore(Semaphore.Options options,
int count)
Create a counting semaphore with the given number of permits. |
Method Summary | |
---|---|
void |
close()
|
protected void |
doWaitForever()
Attempt to wait forever on the semaphore. |
protected void |
doWaitMillis(int timeout)
Attempt to wait for a certain number of milliseconds on a semaphore. |
void |
flush()
Unblock every task that is blocked by the semaphore. |
void |
free()
Free all of the resources associated with this semaphore. |
Pointer |
getPointer()
|
void |
give()
Release the semaphore. |
void |
takeForever()
Take the semaphore. |
void |
takeMillis(int timeout)
Take the semaphore. |
boolean |
tryTake()
Attempt to take the semaphore, but don't block. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int WAIT_FOREVER
Constructor Detail |
---|
public Semaphore(Semaphore.Options options)
options
- The options to create the semaphore with.public Semaphore(Semaphore.Options options, boolean initialState)
options
- The options to create the semaphore with.initialState
- The initial state for the semaphore to have.public Semaphore(Semaphore.Options options, int count)
options
- The options to create the semaphore with.count
- The initial count for the semaphore to hold.Method Detail |
---|
public void flush() throws SemaphoreException
SemaphoreException
public void give() throws SemaphoreException
SemaphoreException
public boolean tryTake() throws SemaphoreException
SemaphoreException
protected void doWaitForever() throws SemaphoreException, java.lang.InterruptedException
SemaphoreException
java.lang.InterruptedException
protected void doWaitMillis(int timeout) throws SemaphoreException, java.lang.InterruptedException
timeout
- The number of milliseconds to wait, at most.
SemaphoreException
java.lang.InterruptedException
public final Pointer getPointer()
public final void takeMillis(int timeout) throws SemaphoreException
timeout
- The number of milliseconds to block.
SemaphoreException
- if the lock can't be take in timeout secondspublic final void takeForever() throws SemaphoreException
SemaphoreException
public final void close() throws SemaphoreException
SemaphoreException
public final void free() throws SemaphoreException
SemaphoreException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |