FireSTARR
Loading...
Searching...
No Matches
fs::sim::Semaphore Class Reference

Provides the ability to limit number of threads running at once. More...

#include <Model.h>

Collaboration diagram for fs::sim::Semaphore:

Public Member Functions

 Semaphore (const int n)
 Create a Semaphore that limits number of concurrent things running.
 
 Semaphore (const Semaphore &rhs)=delete
 
 Semaphore (Semaphore &&rhs)=delete
 
Semaphoreoperator= (const Semaphore &rhs)=delete
 
Semaphoreoperator= (Semaphore &&rhs)=delete
 
void set_limit (size_t limit)
 
size_t limit ()
 
void notify ()
 Notify something that's waiting so it can run.
 
void wait ()
 Wait until allowed to run.
 

Private Attributes

std::mutex mutex_
 Mutex for parallel access.
 
std::condition_variable cv_
 Condition variable to use for checking count.
 
int used_
 Variable to keep count of threads in use.
 
int limit_
 Limit for number of threads.
 

Detailed Description

Provides the ability to limit number of threads running at once.

Constructor & Destructor Documentation

◆ Semaphore()

fs::sim::Semaphore::Semaphore ( const int n)
inlineexplicit

Create a Semaphore that limits number of concurrent things running.

Parameters
nNumber of concurrent things running

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