#include <SleepyObject.h>
Public Member Functions | |
| SleepyObject () | |
| ctor, inited in a _not_ sleeping state. | |
| virtual | ~SleepyObject () |
| void | runUpdate () |
| runs an update and sleeps if requested when finished until woke up. | |
| void | sleep () |
| returns as soon as the object is not updating anymore and it's resources are safe to access. | |
| void | wakeUp () |
| wakeup the sleeping object. | |
| bool | sleepRequested (void) |
| whether a sleep is currently requested. | |
Protected Member Functions | |
| virtual void | update ()=0 |
| update function to be implemented. | |
Private Attributes | |
| SDL_cond * | m_finishedUpdateCondition |
| SDL_mutex * | m_finishedUpdateMutex |
| SDL_cond * | m_wakeUpCondition |
| SDL_mutex * | m_requestMutex |
| bool | m_sleepRequested |
Call sleep(), it will return as soon as the running update call is done. Call wakeup() to let the object continue its update cycle.
Definition at line 14 of file SleepyObject.h.
| random_utils::SleepyObject::SleepyObject | ( | ) |
ctor, inited in a _not_ sleeping state.
Definition at line 8 of file SleepyObject.cpp.
References m_finishedUpdateCondition, m_finishedUpdateMutex, m_requestMutex, m_sleepRequested, and m_wakeUpCondition.
| random_utils::SleepyObject::~SleepyObject | ( | ) | [virtual] |
Definition at line 18 of file SleepyObject.cpp.
References m_finishedUpdateCondition, m_finishedUpdateMutex, m_requestMutex, and m_wakeUpCondition.
| virtual void random_utils::SleepyObject::update | ( | ) | [protected, pure virtual] |
update function to be implemented.
Referenced by runUpdate().
Here is the caller graph for this function:

| void random_utils::SleepyObject::runUpdate | ( | ) |
runs an update and sleeps if requested when finished until woke up.
Definition at line 47 of file SleepyObject.cpp.
References m_finishedUpdateCondition, m_finishedUpdateMutex, m_requestMutex, m_sleepRequested, m_wakeUpCondition, and update().
Here is the call graph for this function:

| void random_utils::SleepyObject::sleep | ( | ) |
returns as soon as the object is not updating anymore and it's resources are safe to access.
Definition at line 27 of file SleepyObject.cpp.
References m_finishedUpdateCondition, m_finishedUpdateMutex, m_requestMutex, and m_sleepRequested.
| void random_utils::SleepyObject::wakeUp | ( | ) |
wakeup the sleeping object.
Definition at line 81 of file SleepyObject.cpp.
References m_wakeUpCondition.
| bool random_utils::SleepyObject::sleepRequested | ( | void | ) |
whether a sleep is currently requested.
Definition at line 88 of file SleepyObject.cpp.
References m_requestMutex, and m_sleepRequested.
SDL_cond* random_utils::SleepyObject::m_finishedUpdateCondition [private] |
Definition at line 16 of file SleepyObject.h.
Referenced by runUpdate(), sleep(), SleepyObject(), and ~SleepyObject().
SDL_mutex* random_utils::SleepyObject::m_finishedUpdateMutex [private] |
Definition at line 17 of file SleepyObject.h.
Referenced by runUpdate(), sleep(), SleepyObject(), and ~SleepyObject().
SDL_cond* random_utils::SleepyObject::m_wakeUpCondition [private] |
Definition at line 18 of file SleepyObject.h.
Referenced by runUpdate(), SleepyObject(), wakeUp(), and ~SleepyObject().
SDL_mutex* random_utils::SleepyObject::m_requestMutex [private] |
Definition at line 19 of file SleepyObject.h.
Referenced by runUpdate(), sleep(), sleepRequested(), SleepyObject(), and ~SleepyObject().
bool random_utils::SleepyObject::m_sleepRequested [private] |
Definition at line 21 of file SleepyObject.h.
Referenced by runUpdate(), sleep(), sleepRequested(), and SleepyObject().
1.5.1