Esempio n. 1
0
static tb_void_t tb_thread_pool_worker_post(tb_thread_pool_impl_t* impl, tb_size_t post)
{
    // check
    tb_assert_and_check_return(impl && impl->semaphore);

    // the semaphore value
    tb_long_t value = tb_semaphore_value(impl->semaphore);

    // post wait
    if (value >= 0 && (tb_size_t)value < post) 
        tb_semaphore_post(impl->semaphore, post - value);
}
Esempio n. 2
0
static tb_void_t tb_aiop_spak_work(tb_aiop_ptor_impl_t* impl)
{
    // check
    tb_assert_and_check_return(impl && impl->wait && impl->base.aicp);

    // the worker size
    tb_size_t work = tb_atomic_get(&impl->base.aicp->work);

    // the semaphore value
    tb_long_t value = tb_semaphore_value(impl->wait);

    // post wait
    if (value >= 0 && value < work) tb_semaphore_post(impl->wait, work - value);
}