WPILib  2014.0
WPIRoboticsLibraryforFRC
 All Classes Functions Variables Pages
Public Member Functions | Friends | List of all members
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.

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.
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.

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