JeVois  1.5
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
jevois::Semaphore< BB > Class Template Reference

#include <jevois/Types/Semaphore.H>

template<BlockingBehavior BB>
class jevois::Semaphore< BB >

A simple semaphore.

A semaphore is a thread-safe mechanism to share resources between multiple threads of execution.

See this Wikipedia page for basic information: http://en.wikipedia.org/wiki/Semaphore_%28programming%29

This code is derived from the Neuromorphic Robotics Toolkit (NRT).

Template Parameters
BBdefines the blocking behavior and should be a value from jevois::BlockingBehavior

Definition at line 70 of file Semaphore.H.

Inheritance diagram for jevois::Semaphore< BB >:

Public Member Functions

 Semaphore (size_t n=0)
 Create a semaphore with n initial resources. More...
 
void increment (size_t n)
 Release n resources to the semaphore. More...
 
void decrement (size_t n)
 Remove n resources from the semaphore, blocking until they are available or throwing if they are not. More...
 
size_t count () const
 Get the current count. More...
 

Constructor & Destructor Documentation

◆ Semaphore()

template<jevois::BlockingBehavior BB>
jevois::Semaphore< BB >::Semaphore ( size_t  n = 0)
inline

Create a semaphore with n initial resources.

Definition at line 54 of file SemaphoreImpl.H.

Member Function Documentation

◆ count()

template<jevois::BlockingBehavior BB>
size_t jevois::Semaphore< BB >::count ( ) const
inline

Get the current count.

Definition at line 108 of file SemaphoreImpl.H.

◆ decrement()

template<BlockingBehavior BB>
void jevois::Semaphore< BB >::decrement ( size_t  n)

Remove n resources from the semaphore, blocking until they are available or throwing if they are not.

Referenced by jevois::Semaphore< WhenFull >::increment().

◆ increment()

template<jevois::BlockingBehavior BB>
void jevois::Semaphore< BB >::increment ( size_t  n)
inline

Release n resources to the semaphore.

Definition at line 60 of file SemaphoreImpl.H.


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