Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws_task_run #228

Merged
merged 1 commit into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] should we assert(task) too while we're at it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, it'll crash here, in the assert, soooo solid maybe?

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);
}