Exemplo n.º 1
0
Arquivo: mutex.c Projeto: waruqi/tbox
tb_bool_t tb_mutex_enter(tb_mutex_ref_t mutex)
{
    // try to enter for profiler
#ifdef TB_LOCK_PROFILER_ENABLE
    if (tb_mutex_enter_try(mutex)) return tb_true;
#endif

    // enter
    if (mutex && WAIT_OBJECT_0 == WaitForSingleObject((HANDLE)mutex, INFINITE)) return tb_true;

    // failed
    return tb_false;
}
Exemplo n.º 2
0
Arquivo: mutex.c Projeto: ljx0305/tbox
tb_bool_t tb_mutex_enter(tb_mutex_ref_t mutex)
{
    // check
    tb_assert_and_check_return_val(mutex, tb_false);

    // try to enter for profiler
#ifdef TB_LOCK_PROFILER_ENABLE
    if (tb_mutex_enter_try(mutex)) return tb_true;
#endif

    // enter
    if (pthread_mutex_lock((pthread_mutex_t*)mutex)) return tb_false;
    // ok
    else return tb_true;
}