Panda3D

- Main Page
- Packages
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions

# Semaphore Class Reference

A classic semaphore synchronization primitive. More...

List of all members.

## Public Member Functions
| Semaphore (int initial_count)
| Semaphore ()
| acquire ()
| Decrements the internal count.
int | getCount ()
| Returns the current semaphore count.
| output (ostream out)
int | release ()
| Increments the semaphore's internal count.
bool | tryAcquire ()
| If the semaphore can be acquired without blocking, does so and returns true.

## Detailed Description

A classic semaphore synchronization primitive.

A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some other thread calls release().

## Constructor & Destructor Documentation

Semaphore | ( | int | initial_count | ) |

Semaphore | ( |  | ) |

## Member Function Documentation

acquire | ( |  | ) |

Decrements the internal count.

If the count was already at zero, blocks until the count is nonzero, then decrements it.

int getCount | ( |  | ) |

Returns the current semaphore count.

Note that this call is not thread-safe (the count may change at any time).

output | ( | ostream | out | ) |

int release | ( |  | ) |

Increments the semaphore's internal count.

This may wake up another thread blocked on acquire().

Returns the count of the semaphore upon release.

bool tryAcquire | ( |  | ) |

If the semaphore can be acquired without blocking, does so and returns true.

Otherwise, returns false.

All Classes Namespaces Functions Variables Enumerations Enumerator Properties