6 #ifndef ABTI_POOL_H_INCLUDED
7 #define ABTI_POOL_H_INCLUDED
11 static inline ABTI_pool *ABTI_pool_get_ptr(
ABT_pool pool)
13 #ifndef ABT_CONFIG_DISABLE_ERROR_CHECK
18 p_pool = (ABTI_pool *)pool;
22 return (ABTI_pool *)pool;
26 static inline ABT_pool ABTI_pool_get_handle(ABTI_pool *p_pool)
28 #ifndef ABT_CONFIG_DISABLE_ERROR_CHECK
42 static inline void ABTI_pool_inc_num_blocked(ABTI_pool *p_pool)
44 ABTD_atomic_fetch_add_int32(&p_pool->num_blocked, 1);
48 static inline void ABTI_pool_dec_num_blocked(ABTI_pool *p_pool)
50 ABTD_atomic_fetch_sub_int32(&p_pool->num_blocked, 1);
53 static inline void ABTI_pool_push(ABTI_pool *p_pool,
ABT_unit unit,
58 p_pool->required_def.p_push(ABTI_pool_get_handle(p_pool), unit, context);
61 static inline void ABTI_pool_add_thread(ABTI_thread *p_thread,
68 ABTI_pool_push(p_thread->p_pool, p_thread->unit, context);
71 ABTU_ret_err static inline int ABTI_pool_remove(ABTI_pool *p_pool,
75 ABTI_UB_ASSERT(p_pool->deprecated_def.p_remove);
76 return p_pool->deprecated_def.p_remove(ABTI_pool_get_handle(p_pool), unit);
79 static inline ABT_thread ABTI_pool_pop_wait(ABTI_pool *p_pool,
double time_secs,
82 ABTI_UB_ASSERT(p_pool->optional_def.p_pop_wait);
84 p_pool->optional_def.p_pop_wait(ABTI_pool_get_handle(p_pool), time_secs,
91 ABT_thread ABTI_pool_pop_timedwait(ABTI_pool *p_pool,
double abstime_secs);
93 static inline ABT_thread ABTI_pool_pop(ABTI_pool *p_pool,
97 p_pool->required_def.p_pop(ABTI_pool_get_handle(p_pool), context);
102 static inline void ABTI_pool_pop_many(ABTI_pool *p_pool,
ABT_thread *threads,
103 size_t len,
size_t *num,
106 ABTI_UB_ASSERT(p_pool->optional_def.p_pop_many);
107 p_pool->optional_def.p_pop_many(ABTI_pool_get_handle(p_pool), threads, len,
112 static inline void ABTI_pool_push_many(ABTI_pool *p_pool,
const ABT_unit *units,
115 ABTI_UB_ASSERT(p_pool->optional_def.p_push_many);
116 p_pool->optional_def.p_push_many(ABTI_pool_get_handle(p_pool), units, num,
123 static inline void ABTI_pool_retain(ABTI_pool *p_pool)
125 ABTD_atomic_fetch_add_int32(&p_pool->num_scheds, 1);
130 static inline int32_t ABTI_pool_release(ABTI_pool *p_pool)
132 ABTI_ASSERT(ABTD_atomic_acquire_load_int32(&p_pool->num_scheds) > 0);
133 return ABTD_atomic_fetch_sub_int32(&p_pool->num_scheds, 1) - 1;
136 static inline ABT_bool ABTI_pool_is_empty(ABTI_pool *p_pool)
138 return p_pool->required_def.p_is_empty(ABTI_pool_get_handle(p_pool));
141 static inline size_t ABTI_pool_get_size(ABTI_pool *p_pool)
143 ABTI_UB_ASSERT(p_pool->optional_def.p_get_size);
144 return p_pool->optional_def.p_get_size(ABTI_pool_get_handle(p_pool));
147 static inline size_t ABTI_pool_get_total_size(ABTI_pool *p_pool)
150 total_size = ABTI_pool_get_size(p_pool);
151 total_size += ABTD_atomic_acquire_load_int32(&p_pool->num_blocked);