本文整理汇总了C++中mutex_t::acquire方法的典型用法代码示例。如果您正苦于以下问题:C++ mutex_t::acquire方法的具体用法?C++ mutex_t::acquire怎么用?C++ mutex_t::acquire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mutex_t
的用法示例。
在下文中一共展示了mutex_t::acquire方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void media::thread::run(void)
{
fd_set session;
socket_t max;
shell::log(DEBUG1, "starting media thread");
running = true;
socket_t so;
media::proxy *mp;
time_t now;
while(running) {
lock.acquire();
max = hiwater;
memcpy(&session, &connections, sizeof(session));
lock.release();
select(max, &session, NULL, NULL, NULL);
if(!running)
break;
time(&now);
for(so = 0; so < max; ++so) {
#ifdef _MSWINDOWS_
#else
char buf[1];
if(so == control[0] && FD_ISSET(so, &session)) {
if(::read(so, buf, 1) < 1)
shell::log(shell::ERR, "media control failure");
continue;
}
#endif
mp = NULL;
if(!FD_ISSET(so, &session))
continue;
lock.acquire();
mp = proxymap[so];
if(mp->so == INVALID_SOCKET) {
proxymap[so] = NULL;
mp = NULL;
}
if(mp && mp->expires && mp->expires < now)
mp->release(0);
else if(mp)
mp->copy();
lock.release();
}
}
shell::log(DEBUG1, "stopping media thread");
running = true;
}
示例2: release
void media::release(LinkedObject **nat, unsigned expires)
{
assert(nat != NULL);
proxy *member;
time_t expire = 0;
if(!*nat)
return;
if(expires) {
time(&expire);
expire += expires;
}
lock.acquire();
linked_pointer<proxy> pp = *nat;
while(is(pp)) {
member = *pp;
pp.next();
member->release(expires);
member->enlist(&runlist);
}
lock.release();
*nat = NULL;
}
示例3: while
void media::sdp::check_media(char *buffer, size_t len)
{
char *cp, *ep, *sp;
char tmp[128];
char mtype[32];
unsigned tport;
unsigned count = 1;
media::proxy *pp;
if(strnicmp(buffer, "m=", 2))
return;
cp = sp = strchr(buffer, ' ');
if(!cp)
return;
while(isspace(*cp))
++cp;
tport = atoi(cp);
if(!tport)
return;
ep = strchr(cp, '/');
if(ep)
count = atoi(ep + 1);
// at the moment we can only do rtp/rtcp pairs...
if(count > 2) {
result = NULL;
return;
}
mediacount = count;
count = align(count);
ep = strchr(cp, ' ');
if(!ep)
ep = (char *)"";
else while(isspace(*ep))
++ep;
mediaport = tport;
mediacount = count;
tport = 0;
lock.acquire();
String::set(tmp, sizeof(tmp), ep);
while(count--) {
pp = media::get(this);
if(!pp) {
result = NULL;
lock.release();
return;
}
if(!tport)
tport = (pp->port / 2) * 2;
}
lock.release();
*sp = 0;
String::set(mtype, sizeof(mtype), buffer);
if(mediacount > 1)
snprintf(buffer, len, "%s %u/%u %s",
mtype, tport, mediacount, tmp);
else
snprintf(buffer, len, "%s %u %s",
mtype, tport, tmp);
mediacount = align(mediacount);
}