bluecore/engine/Utilities/Kernel.h

84 lines
1.4 KiB
C
Raw Normal View History

2008-01-16 11:45:17 +00:00
#ifndef KERNEL_H_
#define KERNEL_H_
#include "Referenced.h"
#include <vector>
#include <iostream>
#include <exception>
#include <list>
namespace BlueCore
{
class Kernel;
//-----------------------------------------------------------------------------
class KernelTask : public Referenced
{
protected:
~KernelTask()
{
}
public:
KernelTask()
{
}
virtual void tick()
{
}
};
//-----------------------------------------------------------------------------
class Kernel : public Referenced
{
private:
struct KernelTaskContainer
{
ref_ptr<KernelTask> _Task;
int _Priority;
KernelTaskContainer(KernelTask* task, int priority) :
_Task(task), _Priority(priority)
{
}
bool operator <(const KernelTaskContainer& other) const
{
return (_Priority > other._Priority);
}
};
std::list<KernelTaskContainer> _Tasks;
std::list<KernelTaskContainer> _AddedTasks;
std::list<KernelTask*> _RemovedTasks;
bool _Changed;
bool _Clear;
protected:
~Kernel()
{
}
public:
Kernel();
void addTask(KernelTask* task, int priority);
void removeTask(KernelTask* task);
void removeAllTasks();
void setTaskPriority(KernelTask* task, int priority);
bool tick();
};
} // namespace BlueCore
#endif /*KERNEL_H_*/