ARGOBOTS
dce6e727ffc4ca5b3ffc04cb9517c6689be51ec5
|
Go to the documentation of this file.
22 size_t max_threads,
size_t *num_popped,
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;
105 pthread_mutex_destroy(&p_data->
mutex);
106 pthread_cond_destroy(&p_data->
cond);
131 pthread_mutex_lock(&p_data->
mutex);
133 pthread_cond_signal(&p_data->
cond);
134 pthread_mutex_unlock(&p_data->
mutex);
145 pthread_mutex_lock(&p_data->
mutex);
147 for (i = 0; i < num_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);
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);
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);
204 ts_out->tv_sec = (time_t)seconds;
205 ts_out->tv_nsec = (long)((seconds - ts_out->tv_sec) * 1000000000.0);
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);
233 pthread_mutex_lock(&p_data->
mutex);
235 pthread_mutex_unlock(&p_data->
mutex);
243 size_t max_threads,
size_t *num_popped,
250 pthread_mutex_lock(&p_data->
mutex);
252 for (i = 0; i < max_threads; i++) {
259 pthread_mutex_unlock(&p_data->
mutex);
275 pthread_mutex_lock(&p_data->
mutex);
277 pthread_mutex_unlock(&p_data->
mutex);
287 pthread_mutex_lock(&p_data->
mutex);
289 pthread_mutex_unlock(&p_data->
mutex);
ABT_pool_user_get_size_fn p_get_size
static data_t * pool_get_data_ptr(void *p_data)
static ABT_unit pool_create_unit(ABT_pool pool, ABT_thread thread)
ABT_pool_user_init_fn p_init
ABT_pool_remove_fn p_remove
#define ABT_ERR_SYS
Error code: error related to system calls and standard libraries.
int ABT_bool
Boolean type.
static void thread_queue_free(thread_queue_t *p_queue)
uint64_t ABT_pool_context
A pool context value.
struct ABT_thread_opaque * ABT_thread
Work unit handle type.
ABT_pool_user_push_fn p_push
ABT_pool_user_pop_fn p_pop
ABT_pool_user_print_all_fn p_print_all
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 ABTI_thread * ABTI_unit_get_thread_from_builtin_unit(ABT_unit unit)
static ABT_thread ABTI_thread_get_handle(ABTI_thread *p_thread)
ABT_pool_user_free_unit_fn p_free_unit
struct ABT_pool_opaque * ABT_pool
Pool handle type.
static ABT_unit pool_pop_timedwait(ABT_pool pool, double abstime_secs)
ABT_pool_pop_timedwait_fn p_pop_timedwait
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)
ABT_pool_user_pop_wait_fn p_pop_wait
static void pool_push(ABT_pool pool, ABT_unit unit, ABT_pool_context context)
struct ABT_unit_opaque * ABT_unit
Work unit handle type for scheduling.
#define ABTI_ASSERT(cond)
ABTU_ret_err int ABTI_pool_get_fifo_wait_def(ABT_pool_access access, ABTI_pool_required_def *p_required_def, ABTI_pool_optional_def *p_optional_def, ABTI_pool_deprecated_def *p_deprecated_def)
ABTD_atomic_int is_in_pool
#define ABT_SUCCESS
Error code: the routine returns successfully.
static void pool_free(ABT_pool pool)
static ABT_bool thread_queue_is_empty(const thread_queue_t *p_queue)
static int ABTD_atomic_acquire_load_int(const ABTD_atomic_int *ptr)
ABT_pool_user_push_many_fn p_push_many
static ABT_thread pool_pop(ABT_pool pool, ABT_pool_context context)
static ABTU_ret_err int thread_queue_remove(thread_queue_t *p_queue, ABTI_thread *p_thread)
#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)
ABT_pool_user_pop_many_fn p_pop_many
static void ABTU_free(void *ptr)
static void thread_queue_push_tail(thread_queue_t *p_queue, ABTI_thread *p_thread)
static void pool_free_unit(ABT_pool pool, ABT_unit unit)
static ABT_thread pool_pop_wait(ABT_pool pool, double time_secs, ABT_pool_context context)
static void pool_pop_many(ABT_pool pool, ABT_thread *threads, size_t max_threads, size_t *num_popped, ABT_pool_context context)
#define ABTI_CHECK_TRUE(cond, abt_errno)
static ABTI_thread * thread_queue_pop_head(thread_queue_t *p_queue)
static void thread_queue_print_all(const thread_queue_t *p_queue, void *arg, void(*print_fn)(void *, ABT_thread))
static void pool_push_many(ABT_pool pool, const ABT_unit *units, size_t num_units, ABT_pool_context context)
ABT_pool_user_is_empty_fn p_is_empty
static ABT_bool pool_unit_is_in_pool(ABT_unit unit)
static void thread_queue_init(thread_queue_t *p_queue)
static double ABTI_get_wtime(void)
ABT_pool_user_create_unit_fn p_create_unit
ABT_pool_user_free_fn p_free
static void pool_print_all(ABT_pool pool, void *arg, void(*print_fn)(void *, ABT_thread))
static size_t thread_queue_get_size(const thread_queue_t *p_queue)
static int pool_remove(ABT_pool pool, ABT_unit unit)
ABT_pool_access
Pool access type.
static ABT_bool pool_is_empty(ABT_pool pool)
static int pool_init(ABT_pool pool, ABT_pool_config config)