Panda3D

Loading...
Searching...
No Matches
Public Member Functions | List of all members
ConditionVarFullDirect Class Reference

A condition variable, usually used to communicate information about changing state to a thread that is waiting for something to happen. More...

`#include "conditionVarFullDirect.h"`

Inheritance diagram for ConditionVarFullDirect:

## Public Member Functions
| ConditionVarFullDirect (const ConditionVarFullDirect &copy)=delete
| ConditionVarFullDirect (MutexDirect &mutex)
| You must pass in a Mutex to the condition variable constructor.
MutexDirect & | get_mutex () const
| Returns the mutex associated with this condition variable.
void | notify ()
| Informs one of the other threads who are currently blocked on wait() that the relevant condition has changed.
void | notify_all ()
| Informs all of the other threads who are currently blocked on wait() that the relevant condition has changed.
ConditionVarFullDirect & | operator= (const ConditionVarFullDirect &copy)=delete
void | output (std::ostream &out) const
| This method is declared virtual in ConditionVarFullDebug, but non-virtual in ConditionVarFullDirect.
void | wait ()
| Waits on the condition.
void | wait (double timeout)
| Waits on the condition, with a timeout.

## Detailed Description

A condition variable, usually used to communicate information about changing state to a thread that is waiting for something to happen.

A condition variable can be used to "wake up" a thread when some arbitrary condition has changed.

A condition variable is associated with a single mutex, and several condition variables may share the same mutex.

Definition at line 32 of file conditionVarFullDirect.h.

## Constructor & Destructor Documentation

## ◆ ConditionVarFullDirect()

ConditionVarFullDirect::ConditionVarFullDirect | ( | MutexDirect & | mutex | ) |
| inline explicit

You must pass in a Mutex to the condition variable constructor.

This mutex may be shared by other condition variables, if desired. It is the caller's responsibility to ensure the Mutex object does not destruct during the lifetime of the condition variable.

Definition at line 20 of file conditionVarFullDirect.I.

Referenced by ConditionVarFull::ConditionVarFull().

## Member Function Documentation

## ◆ get_mutex()

MutexDirect & ConditionVarFullDirect::get_mutex | ( |  | ) | const
| inline

Returns the mutex associated with this condition variable.

Definition at line 30 of file conditionVarFullDirect.I.

Referenced by ConditionVarFull::get_mutex().

## ◆ notify()

void ConditionVarFullDirect::notify | ( |  | ) |
| inline

Informs one of the other threads who are currently blocked on wait() that the relevant condition has changed.

If multiple threads are currently waiting, at least one of them will be woken up, although there is no way to predict which one. It is possible that more than one thread will be woken up.

The caller must be holding the mutex associated with the condition variable before making this call, which will not release the mutex.

If no threads are waiting, this is a no-op: the notify is lost.

Definition at line 84 of file conditionVarFullDirect.I.

## ◆ notify_all()

void ConditionVarFullDirect::notify_all | ( |  | ) |
| inline

Informs all of the other threads who are currently blocked on wait() that the relevant condition has changed.

The caller must be holding the mutex associated with the condition variable before making this call, which will not release the mutex.

If no threads are waiting, this is a no-op: the notify event is lost.

Definition at line 99 of file conditionVarFullDirect.I.

## ◆ output()

void ConditionVarFullDirect::output | ( | std::ostream & | out | ) | const

This method is declared virtual in ConditionVarFullDebug, but non-virtual in ConditionVarFullDirect.

Definition at line 22 of file conditionVarFullDirect.cxx.

## ◆ wait() [1/2]

void ConditionVarFullDirect::wait | ( |  | ) |
| inline

Waits on the condition.

The caller must already be holding the lock associated with the condition variable before calling this function.

wait() will release the lock, then go to sleep until some other thread calls notify() on this condition variable. At that time at least one thread waiting on the same ConditionVarFullDirect will grab the lock again, and then return from wait().

It is possible that wait() will return even if no one has called notify(). It is the responsibility of the calling process to verify the condition on return from wait, and possibly loop back to wait again if necessary.

Note the semantics of a condition variable: the mutex must be held before wait() is called, and it will still be held when wait() returns. However, it will be temporarily released during the wait() call itself.

Definition at line 52 of file conditionVarFullDirect.I.

## ◆ wait() [2/2]

void ConditionVarFullDirect::wait | ( | double | timeout | ) |
| inline

Waits on the condition, with a timeout.

The function will return when the condition variable is notified, or the timeout occurs. There is no way to directly tell which happened, and it is possible that neither in fact happened (spurious wakeups are possible).

See wait() with no parameters for more.

Definition at line 66 of file conditionVarFullDirect.I.

The documentation for this class was generated from the following files:

- panda/src/pipeline/conditionVarFullDirect.h
- panda/src/pipeline/conditionVarFullDirect.cxx
- panda/src/pipeline/conditionVarFullDirect.I