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.

{ init_semaphore( start_cnt_ ); }

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.

{
int ret = sem_destroy( &sem );
__TBB_ASSERT_EX( !ret, NULL );
}

References __TBB_ASSERT_EX, and sem.

## Member Function Documentation

## init_semaphore()

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

inline private

Definition at line 113 of file semaphore.h.

{
int ret = sem_init( &sem, /*shared among threads*/ 0, start_cnt_ );
__TBB_ASSERT_EX( !ret, NULL );
}

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.

{
while( sem_wait( &sem )!=0 )
__TBB_ASSERT( errno==EINTR, NULL );
}

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.

{ 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:

- semaphore.h

__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::internal::semaphore::init_semaphore
void init_semaphore(int start_cnt_)
Definition: semaphore.h:113
tbb::internal::semaphore::sem
sem_t sem
Definition: semaphore.h:112
__TBB_ASSERT_EX
#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

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.