Home ⌂Doc Index ◂Up ▴
Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::internal::binary_semaphore Class Reference

binary_semaphore for concurrent monitor More...

#include <semaphore.h>

Inheritance diagram for tbb::internal::binary_semaphore:
Collaboration diagram for tbb::internal::binary_semaphore:

Public Member Functions

 binary_semaphore ()
 ctor More...
 
 ~binary_semaphore ()
 dtor More...
 
void P ()
 wait/acquire More...
 
void V ()
 post/release More...
 

Private Attributes

sem_t my_sem
 

Additional Inherited Members

- Private Member Functions inherited from tbb::internal::no_copy
 no_copy (const no_copy &)=delete
 
 no_copy ()=default
 

Detailed Description

binary_semaphore for concurrent monitor

Definition at line 222 of file semaphore.h.

Constructor & Destructor Documentation

◆ binary_semaphore()

tbb::internal::binary_semaphore::binary_semaphore ( )
inline

ctor

Definition at line 225 of file semaphore.h.

225  {
226  int ret = sem_init( &my_sem, /*shared among threads*/ 0, 0 );
227  __TBB_ASSERT_EX( !ret, NULL );
228  }
#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 my_sem.

◆ ~binary_semaphore()

tbb::internal::binary_semaphore::~binary_semaphore ( )
inline

dtor

Definition at line 230 of file semaphore.h.

230  {
231  int ret = sem_destroy( &my_sem );
232  __TBB_ASSERT_EX( !ret, NULL );
233  }
#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 my_sem.

Referenced by tbb::internal::concurrent_monitor::thread_context::~thread_context().

Here is the caller graph for this function:

Member Function Documentation

◆ P()

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

wait/acquire

Definition at line 235 of file semaphore.h.

235  {
236  while( sem_wait( &my_sem )!=0 )
237  __TBB_ASSERT( errno==EINTR, NULL );
238  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165

References __TBB_ASSERT, and my_sem.

Referenced by tbb::internal::concurrent_monitor::commit_wait(), tbb::internal::concurrent_monitor::prepare_wait(), and tbb::internal::concurrent_monitor::thread_context::~thread_context().

Here is the caller graph for this function:

◆ V()

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

post/release

Definition at line 240 of file semaphore.h.

240 { sem_post( &my_sem ); }

References my_sem.

Referenced by tbb::internal::concurrent_monitor::abort_all_relaxed(), tbb::internal::concurrent_monitor::notify_all_relaxed(), tbb::internal::concurrent_monitor::notify_one_relaxed(), and tbb::internal::concurrent_monitor::notify_relaxed().

Here is the caller graph for this function:

Member Data Documentation

◆ my_sem

sem_t tbb::internal::binary_semaphore::my_sem
private

Definition at line 242 of file semaphore.h.

Referenced by binary_semaphore(), P(), V(), and ~binary_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.