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

#include <Synchronized.h>

Public Member Functions

 NTSynchronized (NTReentrantSemaphore &)
 
virtual ~NTSynchronized ()
 

Detailed Description

Provide easy support for critical regions. A critical region is an area of code that is always executed under mutual exclusion. Only one task can be executing this code at any time. The idea is that code that manipulates data that is shared between two or more tasks has to be prevented from executing at the same time otherwise a race condition is possible when both tasks try to update the data. Typically semaphores are used to ensure only single task access to the data. Synchronized objects are a simple wrapper around semaphores to help ensure that semaphores are always signaled (semGive) after a wait (semTake).

Definition at line 77 of file OSAL/Synchronized.h.

Constructor & Destructor Documentation

NTSynchronized::NTSynchronized ( NTReentrantSemaphore sem)
explicit

Synchronized class deals with critical regions. Declare a Synchronized object at the beginning of a block. That will take the semaphore. When the code exits from the block it will call the destructor which will give the semaphore. This ensures that no matter how the block is exited, the semaphore will always be released. Use the CRITICAL_REGION(SEM_ID) and END_REGION macros to make the code look cleaner (see header file)

Parameters
semaphoreThe semaphore controlling this critical region.

Definition at line 17 of file OSAL/Synchronized.cpp.

NTSynchronized::~NTSynchronized ( )
virtual

Syncronized destructor. This destructor frees the semaphore ensuring that the resource is freed for the block containing the Synchronized object.

Definition at line 36 of file OSAL/Synchronized.cpp.


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

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