coroutine: make cotask_cancel accept NULL pointers
This allows us to simplify (and fix) the CANCEL_TASK macro
This commit is contained in:
parent
20afdd6c1d
commit
af0efa8b1e
2 changed files with 2 additions and 3 deletions
|
@ -610,7 +610,7 @@ static void *cotask_cancel_in_safe_context(void *arg) {
|
|||
}
|
||||
|
||||
bool cotask_cancel(CoTask *task) {
|
||||
if(cotask_status(task) == CO_STATUS_DEAD) {
|
||||
if(!task || cotask_status(task) == CO_STATUS_DEAD) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -445,8 +445,7 @@ INLINE void cosched_set_invoke_target(CoSched *sched) { _cosched_global = sched;
|
|||
|
||||
DECLARE_EXTERN_TASK(_cancel_task_helper, { BoxedTask task; });
|
||||
|
||||
#define CANCEL_TASK(boxed_task) \
|
||||
(boxed_task.ptr ? cotask_cancel(cotask_unbox(boxed_task)) : false)
|
||||
#define CANCEL_TASK(boxed_task) cotask_cancel(cotask_unbox(boxed_task))
|
||||
|
||||
#define TASK_INDIRECT(iface, task) ( \
|
||||
(void)COTASK_UNUSED_CHECK_##task, \
|
||||
|
|
Loading…
Reference in a new issue