1 Star 0 Fork 0

lovelacelee / libco

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
co_comm.cpp 419 Bytes
Copy Edit Web IDE Raw Blame History
princewen authored 2020-10-27 16:24 . Add hook for gethostbyname_r
#include "co_comm.h"
clsCoMutex::clsCoMutex() {
m_ptCondSignal = co_cond_alloc();
m_iWaitItemCnt = 0;
}
clsCoMutex::~clsCoMutex() { co_cond_free(m_ptCondSignal); }
void clsCoMutex::CoLock() {
if (m_iWaitItemCnt > 0) {
m_iWaitItemCnt++;
co_cond_timedwait(m_ptCondSignal, -1);
} else {
m_iWaitItemCnt++;
}
}
void clsCoMutex::CoUnLock() {
m_iWaitItemCnt--;
co_cond_signal(m_ptCondSignal);
}

Comment ( 0 )

Sign in for post a comment

1
https://gitee.com/lovelacelee/libco.git
git@gitee.com:lovelacelee/libco.git
lovelacelee
libco
libco
master

Search