Changes between Initial Version and Version 1 of KernelTask


Ignore:
Timestamp:
09/27/07 20:45:46 (17 years ago)
Author:
art
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • KernelTask

    v1 v1  
     1= Manual = 
     2 
     3== How to use Kernel/Task subsystem == 
     4 
     5Most of the games has got a main-loop. During the execution of one cycle of the loop a game engine has to perfrom a lot of tasks, e.g. checking user input, rendering, physic update and so on. [[BR]]  
     6nrEngine's Kernel/Task subsystems provides a simple but powerfull interface to manage the main loop. The engine does contains a '''Kernel''' which runs in the background of the engine. A '''Task''' can be bound to the kernel, so that it gets updated every cycle. A task can be any user derived class which has to perform repetitive jobs, e.g. check for user input or stream data from the disk. [[BR]] 
     7Moreover a task can get a specific order number or it can depend on another task. Hence the engine does provide a simple graph based task execution system. The functionality of the nrEngine's kernel is similar to the operating system's one, but in a very simple form. [[BR]] 
     8And finally a task can be shifted to a thread, so that it executes in parallel to the main application. 
     9 
     10The following code show you how to use the engine's kernel subsystem for a simple managment of tasks in your application/game: 
     11{{{ 
     12#include <nrEngine/nrEngine.h> 
     13 
     14using namespace nrEngine; 
     15 
     16//! This is a simpel task performing sound output 
     17class SoundTask :  public ITask 
     18{        
     19public:  
     20   
     21        SoundTask(); 
     22        ~SoundTask(); 
     23 
     24        //! This method will be called when the task stops                               
     25        Result stopTask();       
     26         
     27        //! Task was added to the kernel, so initilize it 
     28        Result onAddTask(); 
     29         
     30        //! This is called every cycle, so that SoundTask can react on it 
     31        Result updateTask(); 
     32 
     33        ... 
     34}; 
     35 
     36void main() 
     37{ 
     38        // Initialize engine 
     39        ... 
     40 
     41 
     42        // Add the sound task to the kernel with a low order number 
     43        Engine::sKernel()->AddTask(new SoundTask(), ORDER_LOW); 
     44 
     45        // Executes engine's kernel, hence execute all tasks which are in the kernel 
     46        // The function returns if there are no more tasks in the kernel (i.e. if all tasks stops) 
     47        Engine::sKernel()->Execute(); 
     48} 
     49}}}   
     50 
     51See also: ["ManualPage"]