| 523 | } |
| 524 | |
| 525 | int bthread_timer_add(bthread_timer_t* id, timespec abstime, |
| 526 | void (*on_timer)(void*), void* arg) { |
| 527 | bthread::TaskControl* c = bthread::get_or_new_task_control(); |
| 528 | if (c == NULL) { |
| 529 | return ENOMEM; |
| 530 | } |
| 531 | bthread::TimerThread* tt = bthread::get_or_create_global_timer_thread(); |
| 532 | if (tt == NULL) { |
| 533 | return ENOMEM; |
| 534 | } |
| 535 | bthread_timer_t tmp = tt->schedule(on_timer, arg, abstime); |
| 536 | if (tmp != 0) { |
| 537 | *id = tmp; |
| 538 | return 0; |
| 539 | } |
| 540 | return ESTOP; |
| 541 | } |
| 542 | |
| 543 | int bthread_timer_del(bthread_timer_t id) { |
| 544 | bthread::TaskControl* c = bthread::get_task_control(); |
no test coverage detected