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);
    54 static inline void ABTI_pool_inc_num_migrations(ABTI_pool *p_pool)
    56     ABTD_atomic_fetch_add_int32(&p_pool->num_migrations, 1);
    60 static inline void ABTI_pool_dec_num_migrations(ABTI_pool *p_pool)
    62     ABTD_atomic_fetch_sub_int32(&p_pool->num_migrations, 1);
    65 #ifdef ABT_CONFIG_DISABLE_POOL_PRODUCER_CHECK    66 static inline void ABTI_pool_push(ABTI_pool *p_pool, 
ABT_unit unit)
    69                         ABTI_self_get_native_thread_id(ABTI_local_get_local()));
    72     p_pool->p_push(ABTI_pool_get_handle(p_pool), unit);
    75 static inline void ABTI_pool_add_thread(ABTI_thread *p_thread)
    82     ABTI_pool_push(p_thread->p_pool, p_thread->unit);
    85 #define ABTI_POOL_PUSH(p_pool, unit, p_producer) ABTI_pool_push(p_pool, unit)    87 #define ABTI_POOL_ADD_THREAD(p_thread, p_producer)                             \    88     ABTI_pool_add_thread(p_thread)    92 static inline int ABTI_pool_push(ABTI_pool *p_pool, 
ABT_unit unit,
    93                                  ABTI_native_thread_id producer_id)
   100     abt_errno = ABTI_pool_set_producer(p_pool, producer_id);
   101     ABTI_CHECK_ERROR(abt_errno);
   104     p_pool->p_push(ABTI_pool_get_handle(p_pool), unit);
   114 static inline int ABTI_pool_add_thread(ABTI_thread *p_thread,
   115                                        ABTI_native_thread_id producer_id)
   124     abt_errno = ABTI_pool_push(p_thread->p_pool, p_thread->unit, producer_id);
   125     ABTI_CHECK_ERROR(abt_errno);
   135 #define ABTI_POOL_PUSH(p_pool, unit, producer_id)                              \   137         abt_errno = ABTI_pool_push(p_pool, unit, producer_id);                 \   138         ABTI_CHECK_ERROR_MSG(abt_errno, "ABTI_pool_push");                     \   141 #define ABTI_POOL_ADD_THREAD(p_thread, producer_id)                            \   143         abt_errno = ABTI_pool_add_thread(p_thread, producer_id);               \   144         ABTI_CHECK_ERROR(abt_errno);                                           \   149 #ifdef ABT_CONFIG_DISABLE_POOL_CONSUMER_CHECK   150 static inline int ABTI_pool_remove(ABTI_pool *p_pool, 
ABT_unit unit)
   155                           ABTI_self_get_native_thread_id(
   156                               ABTI_local_get_local()));
   158     abt_errno = p_pool->p_remove(ABTI_pool_get_handle(p_pool), unit);
   159     ABTI_CHECK_ERROR(abt_errno);
   169 #define ABTI_POOL_REMOVE(p_pool, unit, consumer_id)                            \   170     ABTI_pool_remove(p_pool, unit)   171 #define ABTI_POOL_SET_CONSUMER(p_pool, consumer_id)   175 static inline int ABTI_pool_remove(ABTI_pool *p_pool, 
ABT_unit unit,
   176                                    ABTI_native_thread_id consumer_id)
   182     abt_errno = ABTI_pool_set_consumer(p_pool, consumer_id);
   183     ABTI_CHECK_ERROR(abt_errno);
   185     abt_errno = p_pool->p_remove(ABTI_pool_get_handle(p_pool), unit);
   186     ABTI_CHECK_ERROR(abt_errno);
   196 #define ABTI_POOL_REMOVE(p_pool, unit, consumer_id)                            \   197     ABTI_pool_remove(p_pool, unit, consumer_id)   198 #define ABTI_POOL_SET_CONSUMER(p_pool, consumer_id)                            \   200         abt_errno = ABTI_pool_set_consumer(p_pool, consumer_id);               \   201         ABTI_CHECK_ERROR(abt_errno);                                           \   206 static inline ABT_unit ABTI_pool_pop_timedwait(ABTI_pool *p_pool,
   211     unit = p_pool->p_pop_timedwait(ABTI_pool_get_handle(p_pool), abstime_secs);
   217 static inline ABT_unit ABTI_pool_pop(ABTI_pool *p_pool)
   221     unit = p_pool->p_pop(ABTI_pool_get_handle(p_pool));
   229 static inline void ABTI_pool_retain(ABTI_pool *p_pool)
   231     ABTD_atomic_fetch_add_int32(&p_pool->num_scheds, 1);
   236 static inline int32_t ABTI_pool_release(ABTI_pool *p_pool)
   238     ABTI_ASSERT(ABTD_atomic_acquire_load_int32(&p_pool->num_scheds) > 0);
   239     return ABTD_atomic_fetch_sub_int32(&p_pool->num_scheds, 1) - 1;
   242 static inline size_t ABTI_pool_get_size(ABTI_pool *p_pool)
   244     return p_pool->p_get_size(ABTI_pool_get_handle(p_pool));
   247 static inline size_t ABTI_pool_get_total_size(ABTI_pool *p_pool)
   250     total_size = ABTI_pool_get_size(p_pool);
   251     total_size += ABTD_atomic_acquire_load_int32(&p_pool->num_blocked);
   252     total_size += ABTD_atomic_acquire_load_int32(&p_pool->num_migrations);
 struct ABT_unit_opaque * ABT_unit
#define LOG_EVENT_POOL_PUSH(p_pool, unit, produer_id)
#define LOG_EVENT_POOL_POP(p_pool, unit)
struct ABT_pool_opaque * ABT_pool
#define LOG_EVENT_POOL_REMOVE(p_pool, unit, consumer_id)
#define HANDLE_ERROR_FUNC_WITH_CODE(n)