Task class is an implementation of mail driven thread, for it makes to use Thread and Mail classes in mbed-rtos library easier.
Dependents: mail_driven_task_example
It makes simple to implement asynchronous processing between threads. Task class is an implementation of mail driven thread, for it makes to use Thread and Mail classes in mbed-rtos library easier.
The example of the use of this library, please refer to the following program.
Import programmail_driven_task_example
Simple example of the use of mail_driven_task library
Diff: Task.cpp
- Revision:
- 1:381a6f6263c7
- Parent:
- 0:0c5255720d77
- Child:
- 2:b12e4c1338db
--- a/Task.cpp Mon Dec 22 01:06:33 2014 +0000 +++ b/Task.cpp Thu Dec 25 01:58:14 2014 +0000 @@ -15,16 +15,19 @@ logger = new Logger(cfg->name); } -void Task::init(TaskConfig *config, uint32_t num_of_task) +void Task::init(TaskConfig *cfg, uint32_t num_of_task) { + /** set the lowest priority to main thread. */ osThreadSetPriority(osThreadGetId(), osPriorityIdle); - taskConfig = config; + taskConfig = cfg; taskTable = new Task*[num_of_task]; for (int id = 0; id < num_of_task; id++) { taskTable[id] = new Task(&taskConfig[id]); } + + /** start logger tick */ clock.start(); } @@ -83,6 +86,7 @@ Logger::lv = lv; } + void Task::Logger::setLogStream(Stream *sp) { this->sp = sp;