From 012971aa894a376c19fdbeb71f1c068fd969c2ee Mon Sep 17 00:00:00 2001 From: Colden Cullen Date: Mon, 7 Jan 2019 17:13:11 -0800 Subject: [PATCH] Because I'm tired of ctrl-v my_long_task_name->fn(my_long_task_name, my_long_task_name->arg, AWS_TASK_STATUS_LONG_ENUM); --- include/aws/common/task_scheduler.h | 5 +++++ source/task_scheduler.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/aws/common/task_scheduler.h b/include/aws/common/task_scheduler.h index 59bfe65a8..185b7313e 100644 --- a/include/aws/common/task_scheduler.h +++ b/include/aws/common/task_scheduler.h @@ -51,6 +51,11 @@ AWS_STATIC_IMPL void aws_task_init(struct aws_task *task, aws_task_fn *fn, void task->arg = arg; } +AWS_STATIC_IMPL void aws_task_run(struct aws_task *task, enum aws_task_status status) { + assert(task->fn); + task->fn(task, task->arg, status); +} + struct aws_task_scheduler { struct aws_allocator *alloc; struct aws_priority_queue timed_queue; /* Tasks scheduled to run at specific times */ diff --git a/source/task_scheduler.c b/source/task_scheduler.c index de40c1768..3b57aaad7 100644 --- a/source/task_scheduler.c +++ b/source/task_scheduler.c @@ -191,7 +191,7 @@ static void s_run_all(struct aws_task_scheduler *scheduler, uint64_t current_tim while (!aws_linked_list_empty(&running_list)) { struct aws_linked_list_node *task_node = aws_linked_list_pop_front(&running_list); struct aws_task *task = AWS_CONTAINER_OF(task_node, struct aws_task, node); - task->fn(task, task->arg, status); + aws_task_run(task, status); } } @@ -204,5 +204,5 @@ void aws_task_scheduler_cancel_task(struct aws_task_scheduler *scheduler, struct } else { aws_priority_queue_remove(&scheduler->timed_queue, &task, &task->priority_queue_node); } - task->fn(task, task->arg, AWS_TASK_STATUS_CANCELED); + aws_task_run(task, AWS_TASK_STATUS_CANCELED); }