stops CRON clears all tasks and waits for thread to terminate
| 238 | // stops CRON |
| 239 | // clears all tasks and waits for thread to terminate |
| 240 | void Cron_Stop(void) { |
| 241 | ASSERT(cron != NULL); |
| 242 | |
| 243 | // stop cron main loop |
| 244 | cron->alive = false; |
| 245 | CRON_WakeUp(); |
| 246 | |
| 247 | // wait for thread to terminate |
| 248 | pthread_join(cron->thread, NULL); |
| 249 | |
| 250 | clear_tasks(); |
| 251 | |
| 252 | // free resources |
| 253 | Heap_free(cron->tasks); |
| 254 | pthread_mutex_destroy(&cron->mutex); |
| 255 | pthread_mutex_destroy(&cron->condv_mutex); |
| 256 | pthread_cond_destroy(&cron->condv); |
| 257 | rm_free(cron); |
| 258 | cron = NULL; |
| 259 | } |
| 260 | |
| 261 | // create a new CRON task |
| 262 | CronTaskHandle Cron_AddTask |