Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::internal::semaphore Class Reference

Edsger Dijkstra's counting semaphore. More...

#include <semaphore.h>

Inheritance diagram for tbb::internal::semaphore:
Collaboration diagram for tbb::internal::semaphore:

Public Member Functions

 semaphore (int start_cnt_=0)
 ctor More...
 
 ~semaphore ()
 dtor More...
 
void P ()
 wait/acquire More...
 
void V ()
 post/release More...
 

Private Member Functions

void init_semaphore (int start_cnt_)
 
- Private Member Functions inherited from tbb::internal::no_copy
 no_copy ()
 Allow default construction. More...
 

Private Attributes

sem_t sem
 

Detailed Description

Edsger Dijkstra's counting semaphore.

Definition at line 98 of file semaphore.h.

Constructor & Destructor Documentation

◆ semaphore()

tbb::internal::semaphore::semaphore ( int  start_cnt_ = 0)
inline

ctor

Definition at line 101 of file semaphore.h.

101 { init_semaphore( start_cnt_ ); }
void init_semaphore(int start_cnt_)
Definition: semaphore.h:117

References init_semaphore().

Here is the call graph for this function:

◆ ~semaphore()

tbb::internal::semaphore::~semaphore ( )
inline

dtor

Definition at line 104 of file semaphore.h.

104  {
105  int ret = sem_destroy( &sem );
106  __TBB_ASSERT_EX( !ret, NULL );
107  }
#define __TBB_ASSERT_EX(predicate, comment)
"Extended" version is useful to suppress warnings if a variable is only used with an assert
Definition: tbb_stddef.h:171

References __TBB_ASSERT_EX, and sem.

Member Function Documentation

◆ init_semaphore()

void tbb::internal::semaphore::init_semaphore ( int  start_cnt_)
inlineprivate

Definition at line 117 of file semaphore.h.

117  {
118  int ret = sem_init( &sem, /*shared among threads*/ 0, start_cnt_ );
119  __TBB_ASSERT_EX( !ret, NULL );
120  }
#define __TBB_ASSERT_EX(predicate, comment)
"Extended" version is useful to suppress warnings if a variable is only used with an assert
Definition: tbb_stddef.h:171

References __TBB_ASSERT_EX, and sem.

Referenced by semaphore().

Here is the caller graph for this function:

◆ P()

void tbb::internal::semaphore::P ( )
inline

wait/acquire

Definition at line 109 of file semaphore.h.

109  {
110  while( sem_wait( &sem )!=0 )
111  __TBB_ASSERT( errno==EINTR, NULL );
112  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169

References __TBB_ASSERT, and sem.

Referenced by tbb::internal::input_buffer::sema_P().

Here is the caller graph for this function:

◆ V()

void tbb::internal::semaphore::V ( )
inline

post/release

Definition at line 114 of file semaphore.h.

114 { sem_post( &sem ); }

References sem.

Referenced by tbb::internal::input_buffer::sema_V().

Here is the caller graph for this function:

Member Data Documentation

◆ sem

sem_t tbb::internal::semaphore::sem
private

Definition at line 116 of file semaphore.h.

Referenced by init_semaphore(), P(), V(), and ~semaphore().


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

Copyright © 2005-2019 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.