ocarina/include/idle.h
Anna Schumaker 14879b03fd idle: Update design and unit test
I didn't have any changes to make to the IdleQueue itself, but I did
need to update the unit test and reword a few things in the design.

Signed-off-by: Anna Schuamker <schumaker.anna@gmail.com>
2014-04-06 19:57:06 -04:00

48 lines
621 B
C++

/*
* Copyright 2013 (c) Anna Schumaker.
*/
#ifndef OCARINA_IDLE_H
#define OCARINA_IDLE_H
namespace idle
{
class IdleBase {
protected:
void schedule();
public:
IdleBase();
virtual ~IdleBase();
virtual void run() = 0;
};
template <class T>
class IdleTask : public IdleBase {
private:
void (*func)(T &);
T data;
public:
IdleTask(void (*)(T &), T);
~IdleTask();
void run();
};
template <class T>
static inline void schedule(void (*func)(T &), T param)
{
new IdleTask<T>(func, param);
}
bool run_task();
float get_progress();
};
#include "idle.hpp"
#endif /* OCARINA_IDLE_H */