PR_WaitCondVar 编辑

Waits on a condition.

Syntax

#include <prcvar.h>

/wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRStatus PR_WaitCondVar(
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRCondVar *cvar,
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRIntervalTime timeout);

Parameters

PR_WaitCondVar has the following parameters:

cvar
The condition variable on which to wait.
timeout
The value /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_INTERVAL_NO_TIMEOUT requires that a condition be notified (or the thread interrupted) before it will resume from the wait. The value /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_INTERVAL_NO_WAIT causes the thread to release the lock, possibly causing a rescheduling within the runtime, then immediately attempt to reacquire the lock and resume.

Returns

The function returns one of the following values:

Description

Before the call to PR_WaitCondVar, the lock associated with the condition variable must be held by the calling thread. After a call to PR_WaitCondVar, the lock is released and the thread is blocked in a "waiting on condition" state until another thread notifies the condition or a caller-specified amount of time expires.

When the condition variable is notified, a thread waiting on that condition moves from the "waiting on condition" state to the "ready" state. When scheduled, the thread attempts to reacquire the lock that it held when PR_WaitCondVar was called.

Any value other than /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_INTERVAL_NO_TIMEOUT or /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_INTERVAL_NO_WAIT for the timeout parameter will cause the thread to be rescheduled due to either explicit notification or the expiration of the specified interval. The latter must be determined by treating time as one part of the monitored data being protected by the lock and tested explicitly for an expired interval. To detect the expiration of the specified interval, call PR_IntervalNow before and after the call to PR_WaitCondVar and compare the elapsed time with the specified interval.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:108 次

字数:3906

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文