rvcond_.c
来自「h.248协议源码」· C语言 代码 · 共 86 行
C
86 行
#if (0)
******************************************************************************
Filename :
Description:
******************************************************************************
Copyright (c) 1999 RADVision Inc.
************************************************************************
NOTICE:
This document contains information that is proprietary to RADVision LTD.
No part of this publication may be reproduced in any form whatsoever
without written prior approval by RADVision LTD..
RADVision LTD. reserves the right to revise this publication and make
changes without obligation to notify any person of such revisions or
changes.
******************************************************************************
$Revision:$
$Date:$
$Author: S. Cipolli$
******************************************************************************
#endif
#include "rvcond_.h"
RvCond_* rvCondConstruct_(RvCond_* c, RvMon_* m) {
c->mon = m;
c->count = 0;
rvSemConstruct_(&c->sync, 0);
return c;
}
void rvCondDestruct_(RvCond_* c) {
rvSemDestruct_(&c->sync);
}
void rvCondWait_(RvCond_* c) {
++(c->count);
/* If an rvCondNotify[All] is in progress ... */
if (c->mon->count > 0) {
/* Release rvCondNotify[All] */
rvSemPost_(&c->mon->urgent);
} else {
/* Release resource lock */
rvSemPost_(&c->mon->mutex);
}
/* Wait for rvCondNotify[All] to wake us up */
rvSemWait_(&c->sync);
--(c->count);
}
void rvCondNotify_(RvCond_* c) {
++(c->mon->count);
/* If there are threads waiting in rvCondWait ... */
if (c->count > 0) {
/* Release one thread */
rvSemPost_(&c->sync);
/* Wait for resource to be released */
rvSemWait_(&c->mon->urgent);
}
--(c->mon->count);
}
void rvCondNotifyAll_(RvCond_* c) {
++(c->mon->count);
/* While there are threads waiting in rvMonWait ... */
while (c->count > 0) {
/* Release one thread */
rvSemPost_(&c->sync);
/* Wait for resource to be released */
rvSemWait_(&c->mon->urgent);
}
--(c->mon->count);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?