29 size_t max_threads,
size_t *num_popped,
32 size_t max_threads,
size_t *num_popped,
45 #define POOL_CONTEXT_PUSH_HEAD \
46 (ABT_POOL_CONTEXT_OP_THREAD_CREATE | \
47 ABT_POOL_CONTEXT_OP_THREAD_CREATE_TO | \
48 ABT_POOL_CONTEXT_OP_THREAD_REVIVE | ABT_POOL_CONTEXT_OP_THREAD_REVIVE_TO)
49 #define POOL_CONTEXT_POP_TAIL (ABT_POOL_CONTEXT_OWNER_SECONDARY)
65 ABTI_pool_required_def *p_required_def,
66 ABTI_pool_optional_def *p_optional_def,
67 ABTI_pool_deprecated_def *p_deprecated_def)
116 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
121 ABTI_CHECK_ERROR(abt_errno);
123 access = p_pool->access;
126 ABTD_spinlock_clear(&p_data->mutex);
130 p_pool->data = p_data;
136 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
144 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
151 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
159 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
161 ABTI_thread *p_thread = ABTI_unit_get_thread_from_builtin_unit(unit);
162 ABTD_spinlock_acquire(&p_data->mutex);
168 ABTD_spinlock_release(&p_data->mutex);
174 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
176 ABTI_thread *p_thread = ABTI_unit_get_thread_from_builtin_unit(unit);
187 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
190 ABTD_spinlock_acquire(&p_data->mutex);
192 for (i = 0; i < num_units; i++) {
193 ABTI_thread *p_thread =
194 ABTI_unit_get_thread_from_builtin_unit(units[i]);
201 ABTD_spinlock_release(&p_data->mutex);
208 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
211 for (i = 0; i < num_units; i++) {
212 ABTI_thread *p_thread =
213 ABTI_unit_get_thread_from_builtin_unit(units[i]);
225 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
227 double time_start = 0.0;
230 &p_data->mutex) == 0) {
231 ABTI_thread *p_thread;
237 ABTD_spinlock_release(&p_data->mutex);
239 return ABTI_thread_get_handle(p_thread);
241 if (time_start == 0.0) {
242 time_start = ABTI_get_wtime();
244 double elapsed = ABTI_get_wtime() - time_start;
245 if (elapsed > time_secs)
249 const int sleep_nsecs = 100;
250 struct timespec ts = { 0, sleep_nsecs };
251 nanosleep(&ts, NULL);
257 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
261 &p_data->mutex) == 0) {
263 ABTD_spinlock_release(&p_data->mutex);
265 return ABTI_unit_get_builtin_unit(p_thread);
268 const int sleep_nsecs = 100;
269 struct timespec ts = { 0, sleep_nsecs };
270 nanosleep(&ts, NULL);
272 if (ABTI_get_wtime() > abstime_secs)
279 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
282 &p_data->mutex) == 0) {
283 ABTI_thread *p_thread;
289 ABTD_spinlock_release(&p_data->mutex);
290 return ABTI_thread_get_handle(p_thread);
298 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
300 ABTI_thread *p_thread;
306 return ABTI_thread_get_handle(p_thread);
310 size_t max_threads,
size_t *num_popped,
313 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
315 if (max_threads != 0 &&
317 &p_data->mutex) == 0) {
319 for (i = 0; i < max_threads; i++) {
320 ABTI_thread *p_thread;
328 threads[i] = ABTI_thread_get_handle(p_thread);
331 ABTD_spinlock_release(&p_data->mutex);
338 size_t max_threads,
size_t *num_popped,
341 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
344 for (i = 0; i < max_threads; i++) {
345 ABTI_thread *p_thread;
353 threads[i] = ABTI_thread_get_handle(p_thread);
360 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
362 ABTI_thread *p_thread = ABTI_unit_get_thread_from_builtin_unit(unit);
363 ABTD_spinlock_acquire(&p_data->mutex);
365 ABTD_spinlock_release(&p_data->mutex);
371 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
373 ABTI_thread *p_thread = ABTI_unit_get_thread_from_builtin_unit(unit);
381 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
384 access = p_pool->access;
386 ABTD_spinlock_acquire(&p_data->mutex);
390 ABTD_spinlock_release(&p_data->mutex);
398 ABTI_thread *p_thread = ABTI_unit_get_thread_from_builtin_unit(unit);
399 return ABTD_atomic_acquire_load_int(&p_thread->is_in_pool) ?
ABT_TRUE