Public Member Functions | |
void | sendEvents (bool bSend=true) |
bool | isSendingEvents () const |
Result | Execute () |
Result | OneTick () |
TaskId | AddTask (SharedPtr< ITask > task, TaskOrder order=ORDER_NORMAL, TaskProperty property=TASK_NONE) |
Result | RemoveTask (TaskId id) |
Result | SuspendTask (TaskId id) |
Result | ResumeTask (TaskId id) |
Result | StopExecution () |
Result | ChangeTaskOrder (TaskId id, TaskOrder order=ORDER_NORMAL) |
SharedPtr< ITask > | getTaskByID (TaskId id) |
SharedPtr< ITask > | getTaskByName (const std::string &name) |
Protected Member Functions | |
bool | areSystemTasksAccessable () |
Get information about lock state of the kernel. | |
Protected Attributes | |
std::list< SharedPtr< ITask > > | taskList |
Here kernel does store all currently running tasks. | |
std::list< SharedPtr< ITask > > | pausedTaskList |
Here kernel store all tasks that are sleeping now. | |
Friends | |
class | Engine |
Engine is allowed to create instances of that object. |
Definition at line 85 of file Kernel.h.
void nrEngine::Kernel::sendEvents | ( | bool | bSend = true |
) |
Define if a kernel should send special task events on the engines default channel. Task events are used to inform the application and the engine, that state of certain tasks is changed.
Actually the engine does not need this events, cause engine's modules does not depend on each other, so they do not need this information. However your application could require this messages to react to certain conditions, i.e. clock task is sleeping
bSend | if true the events would be sent, if false so kernel is silent |
bool nrEngine::Kernel::isSendingEvents | ( | ) | const |
Result nrEngine::Kernel::Execute | ( | ) |
Executes the kernel (old school main loop :-) Before main loop is started all tasks will be intialized by calling task function ITask::taskStart() . If taskStart returns error, so this task will be excluded from execution task list.
Definition at line 276 of file Kernel.cpp.
References nrEngine::Log::LOG_KERNEL, nrEngine::OK, OneTick(), taskList, and nrEngine::UNKNOWN_ERROR.
Referenced by nrEngine::Engine::runEngine().
Result nrEngine::Kernel::OneTick | ( | ) |
Executes all task according to their order. After that return back. If you call this function for the first time, so the task will start before updating.
Definition at line 60 of file Kernel.cpp.
References ChangeTaskOrder(), nrEngine::Log::LOG_KERNEL, nrEngine::OK, RemoveTask(), nrEngine::TASK_RUN_ONCE, nrEngine::TASK_RUNNING, nrEngine::TASK_STOPPED, and taskList.
Referenced by Execute(), and nrEngine::Engine::updateEngine().
TaskId nrEngine::Kernel::AddTask | ( | SharedPtr< ITask > | task, | |
TaskOrder | order = ORDER_NORMAL , |
|||
TaskProperty | property = TASK_NONE | |||
) |
Add the given task into our kernel pipeline (main loop) Before task will be added it's ITask::taskInit()) function will be executed The returned task id number can be used to access to the task through kernel.
task | - is a smart pointer to an object implementing ITask-Interface | |
order | Order number for this task (default is ORDER_NORMAL) | |
property | Specifiy the special property of the task |
Definition at line 300 of file Kernel.cpp.
References nrEngine::Log::LOG_KERNEL, nrEngine::OK, nrEngine::ORDER_SYS_LAST, nrEngine::ORDER_SYS_ROOT, nrEngine::orderToString(), pausedTaskList, nrEngine::TASK_IS_THREAD, nrEngine::TASK_STOPPED, nrEngine::TASK_USER, taskList, and nrEngine::UNKNOWN_ERROR.
Referenced by nrEngine::IScript::execute(), and nrEngine::Engine::initializeEngine().
Remove the task from our game loop (pipeline).
id | - id of a task to be removed |
Definition at line 374 of file Kernel.cpp.
References areSystemTasksAccessable(), nrEngine::KERNEL_NO_RIGHTS, nrEngine::KERNEL_NO_TASK_FOUND, nrEngine::Log::LL_WARNING, nrEngine::Log::LOG_KERNEL, nrEngine::OK, nrEngine::TASK_SYSTEM, and nrEngine::UNKNOWN_ERROR.
Referenced by OneTick(), and nrEngine::IScript::updateTask().
Suspend task to prevent it from update. Task will get to sleep.
id | - id of a task to be suspended |
Definition at line 413 of file Kernel.cpp.
References areSystemTasksAccessable(), nrEngine::EventManager::emitSystem(), nrEngine::KERNEL_NO_RIGHTS, nrEngine::KERNEL_NO_TASK_FOUND, nrEngine::Log::LL_WARNING, nrEngine::Log::LOG_KERNEL, nrEngine::OK, pausedTaskList, nrEngine::Engine::sEventManager(), nrEngine::TASK_PAUSED, nrEngine::TASK_SYSTEM, taskList, and nrEngine::UNKNOWN_ERROR.
Resume task from sleeping.
id | - id of a task to waik |
Definition at line 467 of file Kernel.cpp.
References areSystemTasksAccessable(), nrEngine::EventManager::emitSystem(), nrEngine::KERNEL_NO_RIGHTS, nrEngine::KERNEL_NO_TASK_FOUND, nrEngine::Log::LL_WARNING, nrEngine::Log::LOG_KERNEL, nrEngine::OK, pausedTaskList, nrEngine::Engine::sEventManager(), nrEngine::TASK_RUNNING, nrEngine::TASK_SYSTEM, taskList, and nrEngine::UNKNOWN_ERROR.
Result nrEngine::Kernel::StopExecution | ( | ) |
Remove and kill all tasks from the kernel's task list. If no tasks are in the list, so the kernel will stop executing.
Definition at line 526 of file Kernel.cpp.
References nrEngine::Log::LOG_KERNEL, nrEngine::OK, pausedTaskList, taskList, and nrEngine::UNKNOWN_ERROR.
Referenced by nrEngine::Engine::stopEngine().
Changes the order number of task with given id
id | id of a task | |
order | New order number for the task |
Definition at line 559 of file Kernel.cpp.
References areSystemTasksAccessable(), nrEngine::KERNEL_NO_RIGHTS, nrEngine::KERNEL_NO_TASK_FOUND, nrEngine::Log::LL_WARNING, nrEngine::Log::LOG_KERNEL, nrEngine::OK, pausedTaskList, nrEngine::TASK_SYSTEM, nrEngine::TASK_USER, taskList, and nrEngine::UNKNOWN_ERROR.
Referenced by OneTick().
Returns smart pointer to a task with the given id.
id | ID of the task |
Definition at line 685 of file Kernel.cpp.
References areSystemTasksAccessable(), nrEngine::Log::LL_WARNING, nrEngine::Log::LOG_KERNEL, and nrEngine::TASK_SYSTEM.
Referenced by nrEngine::ITask::addTaskDependency().
SharedPtr< ITask > nrEngine::Kernel::getTaskByName | ( | const std::string & | name | ) |
Get the task wich has the same name as the given one.
name | Unique name of the task |
Definition at line 713 of file Kernel.cpp.
References areSystemTasksAccessable(), nrEngine::Log::LL_WARNING, nrEngine::Log::LOG_KERNEL, and nrEngine::TASK_SYSTEM.
Referenced by nrEngine::ITask::addTaskDependency().