Locks 编辑
This chapter describes the NSPR API for creation and manipulation of a mutex of type /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRLock
.
In NSPR, a mutex of type /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRLock
controls locking, and associated condition variables communicate changes in state among threads. When a programmer associates a mutex with an arbitrary collection of data, the mutex provides a protective monitor around the data.
In general, a monitor is a conceptual entity composed of a mutex, one or more condition variables, and the monitored data. Monitors in this generic sense should not be confused with monitors used in Java programming. In addition to /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRLock
, NSPR provides another mutex type, /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRMonitor
, which is reentrant and can have only one associated condition variable. /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRMonitor
is intended for use with Java and reflects the Java approach to thread synchronization.
For an introduction to NSPR thread synchronization, including locks and condition variables, see Introduction to NSPR.
For reference information on NSPR condition variables, see Condition Variables.
Lock Type
Lock Functions
/wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_NewLock
creates a new lock object./wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_DestroyLock
destroys a specified lock object./wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_Lock
locks a specified lock object./wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_Unlock
unlocks a specified lock object.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论