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 ()
 Allow default construction. More...
 

Detailed Description

binary_semaphore for concurrent monitor

Definition at line 226 of file semaphore.h.

Constructor & Destructor Documentation

◆ binary_semaphore()

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

ctor

Definition at line 229 of file semaphore.h.

229  {
230  int ret = sem_init( &my_sem, /*shared among threads*/ 0, 0 );
231  __TBB_ASSERT_EX( !ret, NULL );
232  }
#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 my_sem.

◆ ~binary_semaphore()

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

dtor

Definition at line 234 of file semaphore.h.

234  {
235  int ret = sem_destroy( &my_sem );
236  __TBB_ASSERT_EX( !ret, NULL );
237  }
#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 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 239 of file semaphore.h.

239  {
240  while( sem_wait( &my_sem )!=0 )
241  __TBB_ASSERT( errno==EINTR, NULL );
242  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169

References __TBB_ASSERT, and my_sem.

Referenced by tbb::internal::concurrent_monitor::commit_wait(), tbb::interface7::internal::task_arena_base::internal_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 244 of file semaphore.h.

244 { sem_post( &my_sem ); }

References my_sem.

Referenced by tbb::internal::concurrent_monitor::abort_all_relaxed(), tbb::interface7::internal::wait_task::execute(), 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 246 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-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.