MCPcopy Create free account
hub / github.com/acl-dev/acl / block_wait

Method block_wait

lib_acl_cpp/src/stdlib/thread_cond.cpp:57–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57bool thread_cond::block_wait(bool locked)
58{
59 bool locked_internal;
60
61 if (!locked) {
62 if (!mutex_->lock()) {
63 logger_error("lock error=%s", last_serror());
64 return false;
65 }
66 locked_internal = true;
67 } else {
68 locked_internal = false;
69 }
70
71 int ret = acl_pthread_cond_wait(cond_, mutex_->get_mutex());
72 if (ret) {
73#ifdef ACL_UNIX
74 acl_set_error(ret);
75#endif
76 logger_error("pthread_cond_wait error %s", last_serror());
77 }
78
79 // ����������ڲ�ǰ�����������˴���Ҫ����
80 if (locked_internal && !mutex_->unlock()) {
81 logger_error("mutex unlock error=%s", last_serror());
82 return false;
83 }
84
85 return ret == 0 ? true : false;
86}
87
88bool thread_cond::timed_wait(long long microseconds, bool locked)
89{

Callers

nothing calls this directly

Calls 6

acl_pthread_cond_waitFunction · 0.85
acl_set_errorFunction · 0.85
get_mutexMethod · 0.80
last_serrorFunction · 0.70
lockMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected