Skip to content

Commit

Permalink
aws_task_run(#228)
Browse files Browse the repository at this point in the history
my_long_task_name->fn(my_long_task_name, my_long_task_name->arg, AWS_TASK_STATUS_LONG_ENUM);
  • Loading branch information
ColdenCullen authored Jan 8, 2019
1 parent d7d047e commit 67262a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions include/aws/common/task_scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
4 changes: 2 additions & 2 deletions source/task_scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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);
}

0 comments on commit 67262a9

Please sign in to comment.