-/*] Copyright (c) 2009-2010, Charles McGarvey [**************************
+/*] Copyright (c) 2009-2011, Charles McGarvey [*****************************
**] All rights reserved.
*
-* vi:ts=4 sw=4 tw=75
-*
* Distributable under the terms and conditions of the 2-clause BSD license;
* see the file COPYING for a complete text of the license.
*
-**************************************************************************/
+*****************************************************************************/
#ifndef _MOOF_RUNLOOP_HH_
#define _MOOF_RUNLOOP_HH_
-/**
- * \file runloop.hh
- * Thread timer management class.
- */
-
#include <vector>
#include <boost/noncopyable.hpp>
#include <moof/thread.hh>
+/**
+ * \file runloop.hh
+ * Thread timer management class.
+ */
+
namespace moof {
// forward declarations
class timer;
-
/**
* A runloop is a loop with scheduled timers.
/**
* Do one iteration of the runloop.
+ * \return The number of tasks which were given time.
*/
- void run_once();
-
+ int run_once();
/**
* Start running the runloop.
*/
void stop(int code = 0);
+ bool is_running() const
+ {
+ return !stop_;
+ }
void add_timer(timer& timer);
void remove_timer(timer& timer);
-
private:
bool stop_;
- int code_;
+ int code_;
typedef std::vector<timer*> timer_table;
timer_table timers_;