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 技术交流群。

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

发布评论

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

词条统计

浏览:109 次

字数:2348

最后编辑:7年前

编辑次数:0 次

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