Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.wpi.first.wpilibj.communication
Class Semaphore

    java.lang.Object
      edu.wpi.first.wpilibj.communication.Semaphore

    public class Semaphore

extends Object

Class exposing VxWorks semaphores.

Author:
  dtjones

Nested Class Summary
`static class` | `Semaphore.Options` Options to create a semaphore with.

Field Summary
`static int` | `WAIT_FOREVER` Integer ms value indicating wait forever.

Constructor Summary
`Semaphore(Semaphore.Options options)` Create a new semaphore.
`Semaphore(Semaphore.Options options, boolean initialState)` Create a semaphore with the given initial state.
`Semaphore(Semaphore.Options options, int count)` Create a counting semaphore with the given value.

Method Summary
`void` | `close()` Close the semaphore.
`void` | `flush()` Unblock every task that is blocked by the semaphore.
`void` | `free()` Release all resources associated with the semaphore.
`Pointer` | `getPointer()` Get the pointer to the native semaphore.
`void` | `give()` Release the semaphore.
`void` | `takeForever()` Take the semaphore.
`void` | `takeMillis(int timeout)` Take the semaphore.
`boolean` | `tryTake()`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### WAIT_FOREVER

    public static final int WAIT_FOREVER

  Integer ms value indicating wait forever.

  See Also:
    Constant Field Values

Constructor Detail

### Semaphore

    public Semaphore(Semaphore.Options options)

  Create a new semaphore.

  Parameters:
    `options` - The options to create the semaphore with.

### Semaphore

    public Semaphore(Semaphore.Options options,
                     boolean initialState)

  Create a semaphore with the given initial state.

  Parameters:
    `options` - The options to create the semaphore with.
    `initialState` - The initial state for the semaphore to have.

### Semaphore

    public Semaphore(Semaphore.Options options,
                     int count)

  Create a counting semaphore with the given value.

  Parameters:
    `options` - The options to create the semaphore with.
    `count` - The initial count for the semaphore to hold.

Method Detail

### getPointer

    public Pointer getPointer()

  Get the pointer to the native semaphore.

  Returns:
    Pointer to the native semaphore.

### flush

    public void flush()
               throws SemaphoreException

  Unblock every task that is blocked by the semaphore.

  Throws:
    `SemaphoreException`

### give

    public void give()
              throws SemaphoreException

  Release the semaphore.

  Throws:
    `SemaphoreException`

### takeMillis

    public void takeMillis(int timeout)
                    throws SemaphoreException

  Take the semaphore. Block for timeout milliseconds.

  Parameters:
    `timeout` - The maximum time in milliseconds to block for the semaphore.
  Throws:
    `SemaphoreException` - if the lock can't be take in timeout seconds, or some other semaphore error condition occurs.

### takeForever

    public void takeForever()
                     throws SemaphoreException

  Take the semaphore. Block forever until semaphore is available.

  Throws:
    `SemaphoreException` - if some semaphore error condition occurs.

### tryTake

    public boolean tryTake()
                    throws SemaphoreException

  Throws:
    `SemaphoreException`

### close

    public void close()
               throws SemaphoreException

  Close the semaphore.

  Throws:
    `SemaphoreException`

### free

    public void free()
              throws SemaphoreException

  Release all resources associated with the semaphore.

  Throws:
    `SemaphoreException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

"
For updated information see the Java FRC site
"