Now you can download a copy of these docs so you can use them offline! Download now
ReentrantSemaphore Class Reference

#include <Synchronized.h>

Public Member Functions

int take ()
 
int give ()
 

Friends

class Synchronized
 

Detailed Description

Wrap a vxWorks semaphore (SEM_ID) for easier use in C++. For a static instance, the constructor runs at program load time before main() can spawn any tasks. Use that to fix race conditions in setup code.

This uses a semM semaphore which is "reentrant" in the sense that the owning task can "take" the semaphore more than once. It will need to "give" the semaphore the same number of times to unlock it.

This class is safe to use in static variables because it does not depend on any other C++ static constructors or destructors.

Definition at line 31 of file Synchronized.h.

Member Function Documentation

int ReentrantSemaphore::give ( )
inline

Unlock the semaphore.

Returns
0 for success, -1 for error. If -1, the error will be in errno.

Definition at line 53 of file Synchronized.h.

int ReentrantSemaphore::take ( )
inline

Lock the semaphore, blocking until it's available.

Returns
0 for success, -1 for error. If -1, the error will be in errno.

Definition at line 45 of file Synchronized.h.


The documentation for this class was generated from the following file:

Generated on Sat Apr 26 2014 12:26:46 for WPILibC++ by doxygen 1.8.6