Go to the documentation of this file.
71 ret = pthread_mutex_init(&p_data->mutex, NULL);
76 ret = pthread_cond_init(&p_data->cond, NULL);
78 pthread_mutex_destroy(&p_data->mutex);
83 p_data->num_threads = 0;
84 p_data->p_head = NULL;
85 p_data->p_tail = NULL;
88 p_pool->
data = p_data;
99 pthread_mutex_destroy(&p_data->
mutex);
100 pthread_cond_destroy(&p_data->
cond);
119 pthread_mutex_lock(&p_data->
mutex);
121 p_thread->
p_prev = p_thread;
122 p_thread->
p_next = p_thread;
123 p_data->
p_head = p_thread;
124 p_data->
p_tail = p_thread;
134 p_data->
p_tail = p_thread;
139 pthread_cond_signal(&p_data->
cond);
140 pthread_mutex_unlock(&p_data->
mutex);
150 pthread_mutex_lock(&p_data->
mutex);
153 #if defined(ABT_CONFIG_USE_CLOCK_GETTIME)
155 clock_gettime(CLOCK_REALTIME, &ts);
156 ts.tv_sec += (time_t)time_secs;
157 ts.tv_nsec += (long)((time_secs - (time_t)time_secs) * 1e9);
158 if (ts.tv_nsec > 1e9) {
162 pthread_cond_timedwait(&p_data->
cond, &p_data->
mutex, &ts);
168 pthread_mutex_unlock(&p_data->
mutex);
169 const int sleep_nsecs = 100;
170 struct timespec ts = { 0, sleep_nsecs };
171 nanosleep(&ts, NULL);
172 pthread_mutex_lock(&p_data->
mutex);
180 p_thread = p_data->
p_head;
199 pthread_mutex_unlock(&p_data->
mutex);
207 ts_out->tv_sec = (time_t)seconds;
208 ts_out->tv_nsec = (long)((seconds - ts_out->tv_sec) * 1000000000.0);
218 pthread_mutex_lock(&p_data->
mutex);
223 pthread_cond_timedwait(&p_data->
cond, &p_data->
mutex, &ts);
227 p_thread = p_data->
p_head;
246 pthread_mutex_unlock(&p_data->
mutex);
259 pthread_mutex_lock(&p_data->
mutex);
261 p_thread = p_data->
p_head;
280 pthread_mutex_unlock(&p_data->
mutex);
297 pthread_mutex_lock(&p_data->
mutex);
306 if (p_thread == p_data->
p_head) {
308 }
else if (p_thread == p_data->
p_tail) {
315 pthread_mutex_unlock(&p_data->
mutex);
329 pthread_mutex_lock(&p_data->
mutex);
333 while (num_threads--) {
337 p_thread = p_thread->
p_next;
340 pthread_mutex_unlock(&p_data->
mutex);
ABT_pool_get_size_fn p_get_size
static data_t * pool_get_data_ptr(void *p_data)
#define ABT_ERR_SYS
Error code: error related to system calls and standard libraries.
int ABT_bool
Boolean type.
ABT_pool_remove_fn p_remove
struct ABT_thread_opaque * ABT_thread
Work unit handle type.
ABT_pool_print_all_fn p_print_all
static int pool_free(ABT_pool pool)
static ABT_unit ABTI_unit_get_builtin_unit(ABTI_thread *p_thread)
#define ABT_ERR_POOL
Error code: error related to a pool.
#define ABTI_CHECK_ERROR(abt_errno)
static ABT_bool unit_is_in_pool(ABT_unit unit)
static ABTI_thread * ABTI_unit_get_thread_from_builtin_unit(ABT_unit unit)
struct ABT_pool_opaque * ABT_pool
Pool handle type.
ABTU_ret_err int ABTI_pool_get_fifo_wait_def(ABT_pool_access access, ABTI_pool_def *p_def)
static ABT_unit pool_pop_timedwait(ABT_pool pool, double abstime_secs)
static void convert_double_sec_to_timespec(struct timespec *ts_out, double seconds)
ABT_unit_is_in_pool_fn u_is_in_pool
struct ABT_pool_config_opaque * ABT_pool_config
Pool configuration handle type.
static ABTU_ret_err int ABTU_malloc(size_t size, void **p_ptr)
static void ABTD_atomic_relaxed_store_int(ABTD_atomic_int *ptr, int val)
static int pool_print_all(ABT_pool pool, void *arg, void(*print_fn)(void *, ABT_unit))
struct ABT_unit_opaque * ABT_unit
Work unit handle type for scheduling.
ABT_unit_create_from_thread_fn u_create_from_thread
#define ABTI_ASSERT(cond)
static ABT_unit unit_create_from_thread(ABT_thread thread)
ABT_pool_pop_timedwait_fn p_pop_timedwait
ABTD_atomic_int is_in_pool
static void pool_push(ABT_pool pool, ABT_unit unit)
static void unit_free(ABT_unit *unit)
#define ABT_SUCCESS
Error code: the routine returns successfully.
ABT_pool_pop_wait_fn p_pop_wait
static int ABTD_atomic_acquire_load_int(const ABTD_atomic_int *ptr)
#define ABT_TRUE
True constant for ABT_bool.
static ABTI_pool * ABTI_pool_get_ptr(ABT_pool pool)
#define ABT_FALSE
False constant for ABT_bool.
static size_t pool_get_size(ABT_pool pool)
static void ABTU_free(void *ptr)
static ABT_unit pool_pop_wait(ABT_pool pool, double time_secs)
static ABT_unit pool_pop(ABT_pool pool)
#define ABTI_CHECK_TRUE(cond, abt_errno)
static void ABTD_atomic_release_store_int(ABTD_atomic_int *ptr, int val)
static double ABTI_get_wtime(void)
static int pool_remove(ABT_pool pool, ABT_unit unit)
ABT_pool_access
Pool access type.
static int pool_init(ABT_pool pool, ABT_pool_config config)