Skip to content

Commit

Permalink
release lock on task run...
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Nov 26, 2024
1 parent 2331fca commit 137f838
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions source/darwin/dispatch_queue_event_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,20 @@ static void s_dispatch_queue_destroy_task(void *context) {

while (!aws_linked_list_empty(&dispatch_loop->synced_data.cross_thread_tasks)) {
struct aws_linked_list_node *node = aws_linked_list_pop_front(&dispatch_loop->synced_data.cross_thread_tasks);
aws_mutex_unlock(&dispatch_loop->synced_data.context->lock);
struct aws_task *task = AWS_CONTAINER_OF(node, struct aws_task, node);
task->fn(task, task->arg, AWS_TASK_STATUS_CANCELED);
aws_mutex_lock(&dispatch_loop->synced_data.context->lock);
}
aws_mutex_unlock(&dispatch_loop->synced_data.context->lock);

while (!aws_linked_list_empty(&dispatch_loop->local_cross_thread_tasks)) {
struct aws_linked_list_node *node = aws_linked_list_pop_front(&dispatch_loop->local_cross_thread_tasks);
struct aws_task *task = AWS_CONTAINER_OF(node, struct aws_task, node);
task->fn(task, task->arg, AWS_TASK_STATUS_CANCELED);
}

aws_mutex_lock(&dispatch_loop->synced_data.context->lock);
dispatch_loop->synced_data.suspended = true;
dispatch_loop->synced_data.is_executing = false;
aws_mutex_unlock(&dispatch_loop->synced_data.context->lock);
Expand Down

0 comments on commit 137f838

Please sign in to comment.