Home ⌂Doc Index ◂Up ▴
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 (const no_copy &)=delete
 
 no_copy ()=default
 

Private Attributes

sem_t sem
 

Detailed Description

Edsger Dijkstra's counting semaphore.

Definition at line 94 of file semaphore.h.

Constructor & Destructor Documentation

◆ semaphore()

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

ctor

Definition at line 97 of file semaphore.h.

97 { init_semaphore( start_cnt_ ); }
void init_semaphore(int start_cnt_)
Definition: semaphore.h:113

References init_semaphore().

Here is the call graph for this function:

◆ ~semaphore()

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

dtor

Definition at line 100 of file semaphore.h.

100  {
101  int ret = sem_destroy( &sem );
102  __TBB_ASSERT_EX( !ret, NULL );
103  }
#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:167

References __TBB_ASSERT_EX, and sem.

Member Function Documentation

◆ init_semaphore()

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

Definition at line 113 of file semaphore.h.

113  {
114  int ret = sem_init( &sem, /*shared among threads*/ 0, start_cnt_ );
115  __TBB_ASSERT_EX( !ret, NULL );
116  }
#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:167

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 105 of file semaphore.h.

105  {
106  while( sem_wait( &sem )!=0 )
107  __TBB_ASSERT( errno==EINTR, NULL );
108  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165

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 110 of file semaphore.h.

110 { 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 112 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-2020 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.