6 #ifndef THREAD_QUEUE_H_INCLUDED
7 #define THREAD_QUEUE_H_INCLUDED
18 ABTD_atomic_int is_empty;
26 ABTD_atomic_relaxed_store_int(&p_queue->
is_empty, 1);
36 ABTD_spinlock *p_lock)
38 if (ABTD_atomic_acquire_load_int(&p_queue->
is_empty)) {
42 while (ABTD_spinlock_try_acquire(p_lock)) {
45 if (ABTD_atomic_acquire_load_int(&p_queue->
is_empty)) {
48 }
else if (!ABTD_spinlock_is_locked(p_lock)) {
70 ABTI_thread *p_thread)
73 p_thread->p_prev = p_thread;
74 p_thread->p_next = p_thread;
75 p_queue->
p_head = p_thread;
76 p_queue->
p_tail = p_thread;
78 ABTD_atomic_release_store_int(&p_queue->
is_empty, 0);
80 ABTI_thread *p_head = p_queue->
p_head;
81 ABTI_thread *p_tail = p_queue->
p_tail;
82 p_tail->p_next = p_thread;
83 p_head->p_prev = p_thread;
84 p_thread->p_prev = p_tail;
85 p_thread->p_next = p_head;
86 p_queue->
p_head = p_thread;
89 ABTD_atomic_release_store_int(&p_thread->is_in_pool, 1);
93 ABTI_thread *p_thread)
96 p_thread->p_prev = p_thread;
97 p_thread->p_next = p_thread;
98 p_queue->
p_head = p_thread;
99 p_queue->
p_tail = p_thread;
101 ABTD_atomic_release_store_int(&p_queue->
is_empty, 0);
103 ABTI_thread *p_head = p_queue->
p_head;
104 ABTI_thread *p_tail = p_queue->
p_tail;
105 p_tail->p_next = p_thread;
106 p_head->p_prev = p_thread;
107 p_thread->p_prev = p_tail;
108 p_thread->p_next = p_head;
109 p_queue->
p_tail = p_thread;
112 ABTD_atomic_release_store_int(&p_thread->is_in_pool, 1);
118 ABTI_thread *p_thread = p_queue->
p_head;
123 ABTD_atomic_release_store_int(&p_queue->
is_empty, 1);
125 p_thread->p_prev->p_next = p_thread->p_next;
126 p_thread->p_next->p_prev = p_thread->p_prev;
127 p_queue->
p_head = p_thread->p_next;
131 p_thread->p_prev = NULL;
132 p_thread->p_next = NULL;
133 ABTD_atomic_release_store_int(&p_thread->is_in_pool, 0);
143 ABTI_thread *p_thread = p_queue->
p_tail;
148 ABTD_atomic_release_store_int(&p_queue->
is_empty, 1);
150 p_thread->p_prev->p_next = p_thread->p_next;
151 p_thread->p_next->p_prev = p_thread->p_prev;
152 p_queue->
p_tail = p_thread->p_prev;
156 p_thread->p_prev = NULL;
157 p_thread->p_next = NULL;
158 ABTD_atomic_release_store_int(&p_thread->is_in_pool, 0);
166 ABTI_thread *p_thread)
169 ABTI_CHECK_TRUE(ABTD_atomic_acquire_load_int(&p_thread->is_in_pool) == 1,
176 ABTD_atomic_release_store_int(&p_queue->
is_empty, 1);
178 p_thread->p_prev->p_next = p_thread->p_next;
179 p_thread->p_next->p_prev = p_thread->p_prev;
180 if (p_thread == p_queue->
p_head) {
181 p_queue->
p_head = p_thread->p_next;
182 }
else if (p_thread == p_queue->
p_tail) {
183 p_queue->
p_tail = p_thread->p_prev;
187 ABTD_atomic_release_store_int(&p_thread->is_in_pool, 0);
188 p_thread->p_prev = NULL;
189 p_thread->p_next = NULL;
198 ABTI_thread *p_thread = p_queue->
p_head;
199 while (num_threads--) {
200 ABTI_ASSERT(p_thread);
201 ABT_thread thread = ABTI_thread_get_handle(p_thread);
202 print_fn(arg, thread);
203 p_thread = p_thread->p_next;