PR_SetThreadPrivate 编辑
Sets per-thread private data.
Syntax
#include <prthread.h> /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRStatus PR_SetThreadPrivate(/wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRUintn index, void *priv);
Parameters
PR_SetThreadPrivate
has the following parameters:
index
- An index into the per-thread private data table.
priv
- The per-thread private data, or more likely, a pointer to the data.
Returns
The function returns one of the following values:
- If successful,
PR_SUCCESS
. - If the index is invalid,
PR_FAILURE
.
Description
If the thread already has non-NULL
private data associated with it, and if the destructor function for the index is known (not NULL
), NSPR calls the destructor function associated with the index before setting the new data value. The pointer at the index is swapped with NULL
. If the swapped out value is not NULL
, the destructor function is called. On return, the private data associated with the index is reassigned the new private data's value, even if it is NULL
. The runtime provides no protection for the private data. The destructor is called with the runtime holding no locks. Synchronization is the client's responsibility.
The only way to eliminate thread private data at an index prior to the thread's termination is to call PR_SetThreadPrivate
with a NULL
argument. This causes the index's destructor function to be called, and afterwards assigns a NULL
in the table. A client must not delete the referant object of a non-NULL
private data without first eliminating it from the table.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论