PR_AttachThread 编辑

Obsolete
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

Associates a /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRThread object with an existing native thread.

Syntax

#include <pprthread.h>

/wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRThread* PR_AttachThread(
   /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRThreadType type,
   /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRThreadPriority priority,
   /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRThreadStack *stack);

Parameters

PR_AttachThread has the following parameters:

type
Specifies that the thread is either a user thread (PR_USER_THREAD) or a system thread (PR_SYSTEM_THREAD).
priority
The priority to assign to the thread being attached.
stack
The stack for the thread being attached.

Returns

The function returns one of these values:

  • If successful, a pointer to a /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRThread object.
  • If unsuccessful, for example if system resources are not available, NULL.

Description

You use PR_AttachThread when you want to use NSS functions on the native thread that was not created with NSPR. PR_AttachThread informs NSPR about the new thread by associating a /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRThread object with the native thread.

The thread object is automatically destroyed when it is no longer needed.

You don't need to call PR_AttachThread unless you create your own native thread. /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_Init calls PR_AttachThread automatically for the primordial thread.

Note: As of NSPR release v3.0, PR_AttachThread and /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_DetachThread are obsolete. A native thread not created by NSPR is automatically attached the first time it calls an NSPR function, and automatically detached when it exits.

In NSPR release 19980529B and earlier, it is necessary for a native thread not created by NSPR to call PR_AttachThread before it calls any NSPR functions, and call /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_DetachThread when it is done calling NSPR functions.

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

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

发布评论

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

词条统计

浏览:110 次

字数:3568

最后编辑:7年前

编辑次数:0 次

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