2010 FRC Java API


edu.wpi.first.wpilibj.communication
Class Semaphore

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

public class Semaphore
extends Object

Class exposing C semaphores. Be careful with this as when a semaphore blocks, it stops the entire VM.

Author:
dtjones

Nested Class Summary
static class Semaphore.Options
          Options to create a semaphore with.
 
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.
 void give()
          Release the semaphore.
 void take(double timeout)
          Take the semaphore.
 boolean tryTake()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 inital count for the semaphore to hold.
Method Detail

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

take

public void take(double timeout)
          throws SemaphoreException
Take the semaphore.

Parameters:
timeout - The maximum time to block for the semaphore.
Throws:
SemaphoreException

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

2010 FRC Java API


Copyright © 2006-2009 Sun Microsystems, Inc. All Rights Reserved.