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.

References init_semaphore().

101 { init_semaphore( start_cnt_ ); }
void init_semaphore(int start_cnt_)
Definition: semaphore.h:117
Here is the call graph for this function:

◆ ~semaphore()

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

dtor

Definition at line 104 of file semaphore.h.

References __TBB_ASSERT_EX.

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

Member Function Documentation

◆ init_semaphore()

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

Definition at line 117 of file semaphore.h.

References __TBB_ASSERT, __TBB_ASSERT_EX, h, lock, P(), s, and V().

Referenced by semaphore().

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
Here is the call graph for this function:
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.

References __TBB_ASSERT.

Referenced by init_semaphore(), tbb::internal::input_buffer::sema_P(), and tbb::internal::concurrent_monitor::thread_context::~thread_context().

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

Referenced by init_semaphore(), and tbb::internal::input_buffer::sema_V().

114 { sem_post( &sem ); }
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.


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.