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

Method thread_mutex

lib_acl_cpp/src/stdlib/thread_mutex.cpp:19–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17namespace acl {
18
19thread_mutex::thread_mutex(bool recursive /* = true */)
20{
21 mutex_ = (acl_pthread_mutex_t*)
22 acl_mycalloc(1, sizeof(acl_pthread_mutex_t));
23
24#ifdef ACL_UNIX
25 int ret = pthread_mutexattr_init(&mutex_attr_);
26 if (ret) {
27 SET_ERRNO(ret);
28 logger_fatal("pthread_mutexattr_init error=%s", last_serror());
29 }
30 if (recursive && (ret = pthread_mutexattr_settype(&mutex_attr_,
31 PTHREAD_MUTEX_RECURSIVE))) {
32 SET_ERRNO(ret);
33 logger_fatal("pthread_mutexattr_settype error=%s", last_serror());
34 }
35 ret = acl_pthread_mutex_init(mutex_, &mutex_attr_);
36 if (ret) {
37 SET_ERRNO(ret);
38 logger_fatal("pthread_mutex_init error=%s", last_serror());
39 }
40#else
41 (void) recursive;
42 int ret = acl_pthread_mutex_init(mutex_, NULL);
43 if (ret) {
44 SET_ERRNO(ret);
45 logger_fatal("pthread_mutex_init error=%s", last_serror());
46 }
47#endif
48}
49
50thread_mutex::~thread_mutex()
51{

Callers

nothing calls this directly

Calls 2

acl_pthread_mutex_initFunction · 0.85
last_serrorFunction · 0.70

Tested by

no test coverage detected