Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Sep 11, 2024
1 parent 24ce65b commit 287094f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
17 changes: 7 additions & 10 deletions source/darwin/dispatch_queue_event_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,11 @@ static void s_finalize(void *context) {

static void s_dispatch_event_loop_destroy(void *context) {
// release dispatch loop

struct aws_event_loop *event_loop = context;
struct dispatch_loop *dispatch_loop = event_loop->impl_data;

AWS_LOGF_DEBUG(
AWS_LS_IO_EVENT_LOOP,
"id=%p: Destroy Dispatch Queue Event Loop.", (void*) event_loop);
AWS_LOGF_DEBUG(AWS_LS_IO_EVENT_LOOP, "id=%p: Destroy Dispatch Queue Event Loop.", (void *)event_loop);

aws_mutex_clean_up(&dispatch_loop->synced_data.lock);
aws_mem_release(dispatch_loop->allocator, dispatch_loop);
Expand Down Expand Up @@ -242,9 +240,9 @@ static void s_destroy(struct aws_event_loop *event_loop) {
struct scheduled_service_entry *entry = AWS_CONTAINER_OF(node, struct scheduled_service_entry, node);
scheduled_service_entry_destroy(entry);
}
dispatch_loop->synced_data.suspended = true;
aws_mutex_unlock(&dispatch_loop->synced_data.lock);

dispatch_loop->synced_data.suspended = true;
aws_mutex_unlock(&dispatch_loop->synced_data.lock);
});

/* we don't want it stopped while shutting down. dispatch_release will fail on a suspended loop. */
Expand Down Expand Up @@ -349,9 +347,7 @@ void end_iteration(struct scheduled_service_entry *entry) {
}
}

done:
aws_mutex_unlock(&loop->synced_data.lock);

scheduled_service_entry_destroy(entry);
}

Expand Down Expand Up @@ -419,7 +415,8 @@ static void s_schedule_task_common(struct aws_event_loop *event_loop, struct aws
aws_linked_list_push_back(&dispatch_loop->synced_data.cross_thread_tasks, &task->node);
if (is_empty) {
if (!dispatch_loop->synced_data.scheduling_state.is_executing_iteration) {
if (should_schedule_iteration(&dispatch_loop->synced_data.scheduling_state.scheduled_services, run_at_nanos)) {
if (should_schedule_iteration(
&dispatch_loop->synced_data.scheduling_state.scheduled_services, run_at_nanos)) {
should_schedule = true;
}
}
Expand Down
13 changes: 4 additions & 9 deletions source/event_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,13 @@ static const struct aws_event_loop_configuration s_available_configurations[] =
.style = AWS_EVENT_LOOP_STYLE_COMPLETION_PORT_BASED,
},
#endif
#if TARGET_OS_MAC
#if TARGET_OS_IOS || AWS_USE_DISPATCH_QUEUE
/* use kqueue on OSX and dispatch_queues everywhere else */
{
.name = "Apple Dispatch Queue",
.event_loop_new_fn = aws_event_loop_new_dispatch_queue_with_options,
.style = AWS_EVENT_LOOP_STYLE_COMPLETION_PORT_BASED,
# if TARGET_OS_OSX
.is_default = false,
# else
.is_default = true,
# endif
},
#endif
#if AWS_USE_KQUEUE
Expand Down Expand Up @@ -486,10 +482,10 @@ size_t aws_event_loop_get_load_factor(struct aws_event_loop *event_loop) {
return aws_atomic_load_int(&event_loop->current_load_factor);
}

// DEBUG: TODO: WORKAROUND THE CALLER THREAD VALIDATION ON DISPATCH QUEUE.
// As dispatch queue has ARC support, we could directly release the dispatch queue event loop. Disable the
// caller thread validation on dispatch queue.
#ifndef AWS_USE_DISPATCH_QUEUE
# define AWS_EVENT_LOOP_NOT_CALLER_THREAD(eventloop)
AWS_ASSERT(!aws_event_loop_thread_is_callers_thread(eventloop));
# define AWS_EVENT_LOOP_NOT_CALLER_THREAD(eventloop) AWS_ASSERT(!aws_event_loop_thread_is_callers_thread(eventloop));
#else
# define AWS_EVENT_LOOP_NOT_CALLER_THREAD(eventloop)
#endif
Expand All @@ -500,7 +496,6 @@ void aws_event_loop_destroy(struct aws_event_loop *event_loop) {
}

AWS_ASSERT(event_loop->vtable && event_loop->vtable->destroy);
// DEBUG: TODO: WORKAROUND THE CALLER THREAD VALIDATION ON DISPATCH QUEUE.
AWS_EVENT_LOOP_NOT_CALLER_THREAD(event_loop);

event_loop->vtable->destroy(event_loop);
Expand Down

0 comments on commit 287094f

Please sign in to comment.