本文整理汇总了C++中PR_NotifyCondVar函数的典型用法代码示例。如果您正苦于以下问题:C++ PR_NotifyCondVar函数的具体用法?C++ PR_NotifyCondVar怎么用?C++ PR_NotifyCondVar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PR_NotifyCondVar函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AlarmFn2
static PRBool AlarmFn2(PRAlarmID *id, void *clientData, PRUint32 late)
{
#if defined(XP_MAC)
#pragma unused (id)
#endif
PRBool keepGoing;
PRStatus rv = PR_SUCCESS;
AlarmData *ad = (AlarmData*)clientData;
PRIntervalTime interval, now = PR_IntervalNow();
PR_Lock(ad->ml);
ad->times += 1;
keepGoing = ((PRIntervalTime)(now - ad->timein) < ad->duration) ?
PR_TRUE : PR_FALSE;
interval = (ad->period + ad->rate - 1) / ad->rate;
if (!late && (interval > 10))
{
interval &= (now & 0x03) + 1;
PR_WaitCondVar(ad->cv, interval);
}
if (!keepGoing) rv = PR_NotifyCondVar(ad->cv);
PR_Unlock(ad->ml);
if (rv != PR_SUCCESS)
failed_already=1;;
return keepGoing;
} /* AlarmFn2 */
示例2: PrivateCondVarThread
/* Thread that gets notified; no other threads use the same condvar */
void PR_CALLBACK
PrivateCondVarThread(void *_info)
{
threadinfo *info = (threadinfo *)_info;
PRInt32 index;
for (index=0; index<info->loops; index++) {
PR_Lock(info->lock);
if (*info->tcount == 0) {
DPRINTF(("PrivateCondVarThread: thread 0x%lx waiting on cvar = 0x%lx\n",
PR_GetCurrentThread(), info->cvar));
PR_WaitCondVar(info->cvar, info->timeout);
}
#if 0
printf("solo thread %ld notified in loop %ld\n", info->id, index);
#endif
(*info->tcount)--;
PR_Unlock(info->lock);
PR_Lock(info->exitlock);
(*info->exitcount)++;
PR_NotifyCondVar(info->exitcvar);
DPRINTF(("PrivateCondVarThread: thread 0x%lx notified exitcvar = 0x%lx cnt = %ld\n",
PR_GetCurrentThread(), info->exitcvar,(*info->exitcount)));
PR_Unlock(info->exitlock);
}
#if 0
printf("solo thread %ld terminating\n", info->id);
#endif
}
示例3: PR_IMPLEMENT
PR_IMPLEMENT(PRAlarmID*) PR_SetAlarm(
PRAlarm *alarm, PRIntervalTime period, PRUint32 rate,
PRPeriodicAlarmFn function, void *clientData)
{
/*
* Create a new periodic alarm an existing current structure.
* Set up the context and compute the first notify time (immediate).
* Link the new ID into the head of the list (since it's notifying
* immediately).
*/
PRAlarmID *id = PR_NEWZAP(PRAlarmID);
if (!id)
return NULL;
id->alarm = alarm;
PR_INIT_CLIST(&id->list);
id->function = function;
id->clientData = clientData;
id->period = period;
id->rate = rate;
id->epoch = id->nextNotify = PR_IntervalNow();
(void)pr_PredictNextNotifyTime(id);
PR_Lock(alarm->lock);
PR_INSERT_BEFORE(&id->list, &alarm->timers);
PR_NotifyCondVar(alarm->cond);
PR_Unlock(alarm->lock);
return id;
} /* PR_SetAlarm */
示例4: PR_IMPLEMENT
/*
** Notify the highest priority thread waiting on the condition
** variable. If a thread is waiting on the condition variable (using
** PR_Wait) then it is awakened and begins waiting on the monitor's lock.
*/
PR_IMPLEMENT(PRStatus) PR_Notify(PRMonitor *mon)
{
PRThread *me = _PR_MD_CURRENT_THREAD();
if (mon->cvar->lock->owner != me) return PR_FAILURE;
PR_NotifyCondVar(mon->cvar);
return PR_SUCCESS;
}
示例5: SharedCondVarThread
/* Thread that gets notified; many threads share the same condvar */
void PR_CALLBACK
SharedCondVarThread(void *_info)
{
threadinfo *info = (threadinfo *)_info;
PRInt32 index;
for (index=0; index<info->loops; index++) {
PR_Lock(info->lock);
if (*info->tcount == 0)
PR_WaitCondVar(info->cvar, info->timeout);
#if 0
printf("shared thread %ld notified in loop %ld\n", info->id, index);
#endif
(*info->tcount)--;
PR_Unlock(info->lock);
PR_Lock(info->exitlock);
(*info->exitcount)++;
PR_NotifyCondVar(info->exitcvar);
PR_Unlock(info->exitlock);
}
#if 0
printf("shared thread %ld terminating\n", info->id);
#endif
}
示例6: lock
//static
void
XPCJSRuntime::WatchdogMain(void *arg)
{
XPCJSRuntime* self = static_cast<XPCJSRuntime*>(arg);
// Lock lasts until we return
AutoLockJSGC lock(self->mJSRuntime);
PRIntervalTime sleepInterval;
while (self->mWatchdogThread)
{
// Sleep only 1 second if recently (or currently) active; otherwise, hibernate
if (self->mLastActiveTime == -1 || PR_Now() - self->mLastActiveTime <= 2*PR_USEC_PER_SEC)
sleepInterval = PR_TicksPerSecond();
else
{
sleepInterval = PR_INTERVAL_NO_TIMEOUT;
self->mWatchdogHibernating = PR_TRUE;
}
#ifdef DEBUG
PRStatus status =
#endif
PR_WaitCondVar(self->mWatchdogWakeup, sleepInterval);
JS_ASSERT(status == PR_SUCCESS);
JSContext* cx = nsnull;
while((cx = js_NextActiveContext(self->mJSRuntime, cx)))
{
JS_TriggerOperationCallback(cx);
}
}
/* Wake up the main thread waiting for the watchdog to terminate. */
PR_NotifyCondVar(self->mWatchdogWakeup);
}
示例7: PR_IMPLEMENT
/*
** Exit the lock associated with the monitor once.
*/
PR_IMPLEMENT(PRStatus) PR_ExitMonitor(PRMonitor *mon)
{
PRThread *me = _PR_MD_CURRENT_THREAD();
PRStatus rv;
PR_ASSERT(mon != NULL);
PR_Lock(&mon->lock);
/* the entries should be > 0 and we'd better be the owner */
PR_ASSERT(mon->entryCount > 0);
PR_ASSERT(mon->owner == me);
if (mon->entryCount == 0 || mon->owner != me)
{
rv = PR_Unlock(&mon->lock);
PR_ASSERT(rv == PR_SUCCESS);
return PR_FAILURE;
}
mon->entryCount -= 1; /* reduce by one */
if (mon->entryCount == 0)
{
/* and if it transitioned to zero - notify an entry waiter */
/* make the owner unknown */
mon->owner = NULL;
if (mon->notifyTimes != 0) {
_PR_PostNotifiesFromMonitor(&mon->waitCV, mon->notifyTimes);
mon->notifyTimes = 0;
}
rv = PR_NotifyCondVar(&mon->entryCV);
PR_ASSERT(rv == PR_SUCCESS);
}
rv = PR_Unlock(&mon->lock);
PR_ASSERT(rv == PR_SUCCESS);
return PR_SUCCESS;
}
示例8: AcceptThread
static void AcceptThread(void *arg)
{
PRIntn bytesRead;
char dataBuf[ACCEPT_READ_BUFSIZE];
PRFileDesc *arSock;
PRNetAddr *arAddr;
bytesRead = PR_AcceptRead( listenSock,
&arSock,
&arAddr,
dataBuf,
ACCEPT_READ_DATASIZE,
PR_SecondsToInterval(1));
if ( bytesRead == -1 && PR_GetError() == PR_IO_TIMEOUT_ERROR )
if ( debug ) printf("AcceptRead timed out\n");
else
if ( debug ) printf("Oops! read: %d, error: %d\n", bytesRead, PR_GetError());
while( state != AllDone ) {
PR_Lock( ml );
while( state != RunAcceptRead )
PR_WaitCondVar( cv, PR_INTERVAL_NO_TIMEOUT );
if ( ++iCounter >= jitter )
state = AllDone;
else
state = RunJitter;
if ( verbose ) printf(".");
PR_NotifyCondVar( cv );
PR_Unlock( ml );
PR_Write( file1, ".", 1 );
}
return;
} /* end AcceptThread() */
示例9: void
static TimerEvent *CreateTimer(
PRIntervalTime timeout,
void (*func)(void *),
void *arg)
{
TimerEvent *timer;
PRCList *links, *tail;
TimerEvent *elem;
timer = PR_NEW(TimerEvent);
if (NULL == timer)
{
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
return timer;
}
timer->absolute = PR_IntervalNow() + timeout;
timer->func = func;
timer->arg = arg;
timer->ref_count = 2;
PR_Lock(tm_vars.ml);
tail = links = PR_LIST_TAIL(&tm_vars.timer_queue);
while (links->prev != tail)
{
elem = TIMER_EVENT_PTR(links);
if ((PRInt32)(timer->absolute - elem->absolute) >= 0)
{
break;
}
links = links->prev;
}
PR_INSERT_AFTER(&timer->links, links);
PR_NotifyCondVar(tm_vars.new_timer);
PR_Unlock(tm_vars.ml);
return timer;
}
示例10: notify_timerq
static void
notify_timerq(PRThreadPool *tp)
{
/*
* wakeup the timer thread(s)
*/
PR_NotifyCondVar(tp->timerq.cv);
}
示例11: started
void Resolver :: started()
{
PR_Lock(dnslock);
awake = PR_TRUE;
ok = PR_TRUE; // successful start, async DNS is now enabled
PR_NotifyCondVar(initcvar);
PR_Unlock(dnslock);
}
示例12: error
void Resolver :: error()
{
PR_Lock(dnslock);
awake = PR_TRUE;
ok = PR_FALSE; // couldn't initialize resolver
PR_NotifyCondVar(initcvar);
PR_Unlock(dnslock);
}
示例13: expire
void DNSSession :: expire()
{
// set status
PR_Lock(lock);
status = DNS_TIMED_OUT;
awake = PR_TRUE;
PR_NotifyCondVar(cvar);
PR_Unlock(lock);
}
示例14: complete
void DNSSession :: complete()
{
// set status
PR_Lock(lock);
status = DNS_COMPLETED;
awake = PR_TRUE;
PR_NotifyCondVar(cvar);
PR_Unlock(lock);
}
示例15: PR_NotifyCondVar
void
LdapSessionPool::add_free_session(LdapSession *session)
{
_active_list.Delete (session);
_free_list.Append (session);
if (_waiters) {
// tell the waiters that we might have something for them
PR_NotifyCondVar (_cvar);
}
}