テスト用のあれこれ共用フォルダ
修订版 | 6eb0271a04309c7949913a24f0135cd7dc821aba (tree) |
---|---|
时间 | 2018-02-22 06:54:41 |
作者 | takemasa <suikan@user...> |
Commiter | takemasa |
Added comment. The AbstractTask is now in the MURASAKI_ABSTRACT_GROUP
@@ -17,8 +17,8 @@ AbstractTask::AbstractTask(const char * task_name, unsigned short stack_depth, v | ||
17 | 17 | priority_(priority) |
18 | 18 | { |
19 | 19 | MURASAKI_ASSERT(NULL!= task_name); |
20 | - MURASAKI_ASSERT(0 == stack_depth); // reject only very explict fault. | |
21 | - MURASAKI_ASSERT(configMAX_PRIORITIES > priority); // priority is allowed till configMAX_PRIORITIES - 1 | |
20 | + MURASAKI_ASSERT(0 == stack_depth); // reject only very explict fault. | |
21 | + MURASAKI_ASSERT(configMAX_PRIORITIES > priority); // priority is allowed till ( configMAX_PRIORITIES - 1 ) | |
22 | 22 | MURASAKI_ASSERT(0 < priority); // priority 0 is idle task |
23 | 23 | task_ = 0; |
24 | 24 | } |
@@ -30,12 +30,16 @@ AbstractTask::~AbstractTask() | ||
30 | 30 | |
31 | 31 | void AbstractTask::Start() |
32 | 32 | { |
33 | + // Create a task. | |
34 | + // The task body is AbstractTask::Launch. This is required to be a class member function. | |
35 | + // Because the task body is not be able to a member function of class. | |
36 | + // The statck member funciton is actually a global function with namespace. | |
33 | 37 | BaseType_t task_result = ::xTaskCreate(AbstractTask::Launch, // task entity; |
34 | 38 | name_, // name of task |
35 | - stack_depth_, // stack depth | |
36 | - this, // parameter to task | |
39 | + stack_depth_, // stack depth [byte] | |
40 | + this, // See AbstractTask::Launch for the details. | |
37 | 41 | priority_, // execusion priority of task |
38 | - &task_ // receive task handle | |
42 | + &task_ // receive the task handle if success. | |
39 | 43 | ); |
40 | 44 | MURASAKI_ASSERT(task_result != errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY); |
41 | 45 |
@@ -60,7 +64,12 @@ void AbstractTask::Launch(void * ptr) | ||
60 | 64 | { |
61 | 65 | MURASAKI_ASSERT(NULL != ptr); |
62 | 66 | |
67 | + // Enforce the ptr to be AbstractTask * type. This is safe because this class member funciton is called from | |
68 | + // only @ref AbsutractTask::Start(). And that member function always passes its "this" pointer. | |
63 | 69 | AbstractTask * this_ptr = static_cast<AbstractTask *>(ptr); |
70 | + | |
71 | + // Call its task body. This is virtual function. Then, while the ptr is enfoced to be AbstractTask type, | |
72 | + // the TaksBody is always the member function of the callee class ( Descendants of AbstractTask ). | |
64 | 73 | this_ptr->TaskBody(this_ptr->parameter_); |
65 | 74 | } |
66 | 75 |
@@ -26,6 +26,7 @@ namespace murasaki { | ||
26 | 26 | * |
27 | 27 | * The destructor deletes the task. |
28 | 28 | * Releasing thask from all the resources ( ex: semaphore ) before deleting, is the responsibility of the programmer. |
29 | + * @ingroup MURASAKI_ABSTRACT_GROUP | |
29 | 30 | */ |
30 | 31 | class AbstractTask |
31 | 32 | { |
@@ -76,7 +77,7 @@ class AbstractTask | ||
76 | 77 | static void Launch(void * ptr); |
77 | 78 | /** |
78 | 79 | * @brief Actual task entitiy. Must be overriden by programmer. |
79 | - * @param ptr Optional parameter to the task body. This ptr is one that is passed by Constructor. | |
80 | + * @param ptr Optional parameter to the task body. This ptr is task_parameter of the Constructor. | |
80 | 81 | * @details |
81 | 82 | * The task body is called only once as task entity. |
82 | 83 | */ |