diff options
author | Nicolas 'Pixel' Noble <pixel@nobis-crew.org> | 2013-01-18 09:15:34 -0800 |
---|---|---|
committer | Nicolas 'Pixel' Noble <pixel@nobis-crew.org> | 2013-01-18 09:15:34 -0800 |
commit | 8e6f94ffffcc992c24393be15d8f984a5c5eef6f (patch) | |
tree | a77e51cb4c62752a9b6f84270763f7e6f2e235b0 /src | |
parent | 8c5bdc2344dbc6c1629e258b7965442046600584 (diff) |
Adding a sleep() paradigm to tasks.
Diffstat (limited to 'src')
-rw-r--r-- | src/Task.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Task.cc b/src/Task.cc index 4465203..9a00f30 100644 --- a/src/Task.cc +++ b/src/Task.cc @@ -174,6 +174,13 @@ struct ev_loop * Balau::Task::getLoop() { return getTaskMan()->getLoop(); } +void Balau::Task::sleep(double timeout) { + AAssert(!m_stackless && !m_okayToEAgain, "You can only call sleep on simple tasks."); + Events::Timeout evt(timeout); + waitFor(&evt); + yield(); +} + void Balau::Events::BaseEvent::doSignal() { Printer::elog(E_TASK, "Event at %p (%s) is signaled with cb %p and task %p", this, ClassName(this).c_str(), m_cb, m_task); m_signal = true; |