Skip to content

Commit

Permalink
refact dispatch queue with internal context
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Nov 26, 2024
1 parent 2461b43 commit d4bec93
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 112 deletions.
12 changes: 8 additions & 4 deletions source/darwin/dispatch_queue.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef AWS_IO_PRIVATE_DISPATCH_QUEUE_H
#define AWS_IO_PRIVATE_DISPATCH_QUEUE_H
#ifndef AWS_IO_DARWIN_DISPATCH_QUEUE_H
#define AWS_IO_DARWIN_DISPATCH_QUEUE_H
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
Expand Down Expand Up @@ -37,20 +37,24 @@ struct dispatch_scheduling_state {
struct aws_linked_list scheduled_services;
};

struct dispatch_loop;
struct dispatch_loop_context;

struct dispatch_loop {
struct aws_allocator *allocator;
struct aws_ref_count ref_count;
dispatch_queue_t dispatch_queue;
struct aws_task_scheduler scheduler;
struct aws_linked_list local_cross_thread_tasks;
struct aws_event_loop *base_loop;

/* Apple dispatch queue uses the id string to identify the dispatch queue */
struct aws_string *dispatch_queue_id;

struct {
struct dispatch_scheduling_state scheduling_state;
struct aws_linked_list cross_thread_tasks;
struct aws_mutex lock;
struct dispatch_loop_context *context;
bool suspended;
/* `is_executing` flag and `current_thread_id` together are used to identify the excuting
* thread id for dispatch queue. See `static bool s_is_on_callers_thread(struct aws_event_loop *event_loop)`
Expand All @@ -63,4 +67,4 @@ struct dispatch_loop {
bool is_destroying;
};

#endif /* #ifndef AWS_IO_PRIVATE_DISPATCH_QUEUE_H */
#endif /* #ifndef AWS_IO_DARWIN_DISPATCH_QUEUE_H */
Loading

0 comments on commit d4bec93

Please sign in to comment.