PR_Interrupt 编辑

Sets the interrupt request for a target thread.

Syntax

#include <prthread.h>

/wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRStatus PR_Interrupt(/wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRThread *thread);

Parameter

PR_Interrupt has the following parameter:

thread
The thread whose interrupt request you want to set.

Returns

The function returns one of the following values:

  • If the specified thread is currently blocked, PR_SUCCESS.
  • Otherwise, PR_FAILURE.

Description

The purpose of PR_Interrupt is to request that a thread performing some task stop what it is doing and return to some control point. It is assumed that a control point has been mutually arranged between the thread doing the interrupting and the thread being interrupted. When the interrupted thread reaches the prearranged point, it can communicate with its peer to discover the real reason behind the change in plans.

The interrupt request remains in the thread's state until it is delivered exactly once or explicitly canceled. The interrupted thread returns PR_FAILURE (-1) with an error code (see /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_GetError) for blocking operations that return a /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRStatus (such as I/O operations, monitor waits, or waiting on a condition). To check whether the thread was interrupted, compare the result of /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_GetError with PR_PENDING_INTERRUPT_ERROR.

PR_Interrupt may itself fail if the target thread is invalid.

Bugs

PR_Interrupt has the following limitations and known bugs:

  • There can be a delay for a thread to be interrupted from a blocking I/O function. In all NSPR implementations, the maximum delay is at most five seconds. In the pthreads-based implementation on Unix, the maximum delay is 0.1 seconds.
  • File I/O is considered instantaneous, so file I/O functions cannot be interrupted. Unfortunately the standard input, output, and error streams are treated as files by NSPR, so a PR_Read call on PR_STDIN cannot be interrupted even though it may block indefinitely.
  • In the NT implementation, PR_Connect cannot be interrupted.
  • In the NT implementation, a file descriptor is not usable and must be closed after an I/O function on the file descriptor is interrupted. See the memo Using IO Timeout and Interrupt on NT for details.

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

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

发布评论

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

词条统计

浏览:69 次

字数:3525

最后编辑:7 年前

编辑次数:0 次

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