22 size_t max_threads,
size_t *num_popped,
35 pthread_mutex_t mutex;
48 ABTI_pool_required_def *p_required_def,
49 ABTI_pool_optional_def *p_optional_def,
50 ABTI_pool_deprecated_def *p_deprecated_def)
77 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
81 ABTI_CHECK_ERROR(abt_errno);
83 ret = pthread_mutex_init(&p_data->mutex, NULL);
88 ret = pthread_cond_init(&p_data->cond, NULL);
90 pthread_mutex_destroy(&p_data->mutex);
96 p_pool->data = p_data;
102 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
105 pthread_mutex_destroy(&p_data->mutex);
106 pthread_cond_destroy(&p_data->cond);
112 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
119 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
127 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
129 ABTI_thread *p_thread = ABTI_unit_get_thread_from_builtin_unit(unit);
131 pthread_mutex_lock(&p_data->mutex);
133 pthread_cond_signal(&p_data->cond);
134 pthread_mutex_unlock(&p_data->mutex);
141 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
145 pthread_mutex_lock(&p_data->mutex);
147 for (i = 0; i < num_units; i++) {
148 ABTI_thread *p_thread =
149 ABTI_unit_get_thread_from_builtin_unit(units[i]);
152 if (num_units == 1) {
154 pthread_cond_signal(&p_data->cond);
157 pthread_cond_broadcast(&p_data->cond);
159 pthread_mutex_unlock(&p_data->mutex);
167 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
169 pthread_mutex_lock(&p_data->mutex);
171 #if defined(ABT_CONFIG_USE_CLOCK_GETTIME)
173 clock_gettime(CLOCK_REALTIME, &ts);
174 ts.tv_sec += (time_t)time_secs;
175 ts.tv_nsec += (long)((time_secs - (time_t)time_secs) * 1e9);
176 if (ts.tv_nsec > 1e9) {
180 pthread_cond_timedwait(&p_data->cond, &p_data->mutex, &ts);
184 double start_time = ABTI_get_wtime();
185 while (ABTI_get_wtime() - start_time < time_secs) {
186 pthread_mutex_unlock(&p_data->mutex);
187 const int sleep_nsecs = 100;
188 struct timespec ts = { 0, sleep_nsecs };
189 nanosleep(&ts, NULL);
190 pthread_mutex_lock(&p_data->mutex);
191 if (p_data->num_threads > 0)
197 pthread_mutex_unlock(&p_data->mutex);
198 return ABTI_thread_get_handle(p_thread);
204 ts_out->tv_sec = (time_t)seconds;
205 ts_out->tv_nsec = (long)((seconds - ts_out->tv_sec) * 1000000000.0);
210 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
212 pthread_mutex_lock(&p_data->mutex);
216 pthread_cond_timedwait(&p_data->cond, &p_data->mutex, &ts);
219 pthread_mutex_unlock(&p_data->mutex);
221 return ABTI_unit_get_builtin_unit(p_thread);
230 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
233 pthread_mutex_lock(&p_data->mutex);
235 pthread_mutex_unlock(&p_data->mutex);
236 return ABTI_thread_get_handle(p_thread);
243 size_t max_threads,
size_t *num_popped,
247 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
250 pthread_mutex_lock(&p_data->mutex);
252 for (i = 0; i < max_threads; i++) {
256 threads[i] = ABTI_thread_get_handle(p_thread);
259 pthread_mutex_unlock(&p_data->mutex);
267 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
269 ABTI_thread *p_thread = ABTI_unit_get_thread_from_builtin_unit(unit);
272 ABTI_CHECK_TRUE(ABTD_atomic_acquire_load_int(&p_thread->is_in_pool) == 1,
275 pthread_mutex_lock(&p_data->mutex);
277 pthread_mutex_unlock(&p_data->mutex);
284 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
287 pthread_mutex_lock(&p_data->mutex);
289 pthread_mutex_unlock(&p_data->mutex);
296 ABTI_thread *p_thread = ABTI_unit_get_thread_from_builtin_unit(unit);
297 return ABTD_atomic_acquire_load_int(&p_thread->is_in_pool) ?
ABT_TRUE