Bug 1395259 Comment 11 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

The Windows task queue stuff can be implemented in terms of [APCs](https://docs.microsoft.com/en-us/windows/desktop/sync/asynchronous-procedure-calls) and [waitable timers](https://docs.microsoft.com/en-us/windows/desktop/sync/waitable-timer-objects).

Each thread has in implicit queue for user-mode APCs. Use [`QueueUserAPC`](https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-queueuserapc) to post them, and one of the [alterable wait functions](https://docs.microsoft.com/en-us/windows/desktop/sync/wait-functions#alertable-wait-functions) to block while waiting for an APC to fire.

Waitable timers integrate with the wait functions by signaling a `HANDLE` and optionally by posting an APC.

The quit message could be implemented in a couple of ways: You could either use an event object that `ProcessQueuedMessages` waits on via `WaitForSingleObjectEx` or `WaitForMultipleObjectsEx`, or you could just enqueue a special APC that signals that it is time for the thread to break out of its event loop. Which one you choose probably depends on whether or not you want the event queue to be drained prior to quitting.
The Windows task queue stuff can be implemented in terms of [APCs](https://docs.microsoft.com/en-us/windows/desktop/sync/asynchronous-procedure-calls) and [waitable timers](https://docs.microsoft.com/en-us/windows/desktop/sync/waitable-timer-objects).

Each thread has an implicit queue for user-mode APCs. Use [`QueueUserAPC`](https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-queueuserapc) to post them, and one of the [alterable wait functions](https://docs.microsoft.com/en-us/windows/desktop/sync/wait-functions#alertable-wait-functions) to block while waiting for an APC to fire.

Waitable timers integrate with the wait functions by signaling a `HANDLE` and optionally by posting an APC.

The quit message could be implemented in a couple of ways: You could either use an event object that `ProcessQueuedMessages` waits on via `WaitForSingleObjectEx` or `WaitForMultipleObjectsEx`, or you could just enqueue a special APC that signals that it is time for the thread to break out of its event loop. Which one you choose probably depends on whether or not you want the event queue to be drained prior to quitting.
The Windows task queue stuff can be implemented in terms of [APCs](https://docs.microsoft.com/en-us/windows/desktop/sync/asynchronous-procedure-calls) and [waitable timers](https://docs.microsoft.com/en-us/windows/desktop/sync/waitable-timer-objects).

Each thread has an implicit queue for user-mode APCs. Use [`QueueUserAPC`](https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-queueuserapc) to post them, and one of the [alertable wait functions](https://docs.microsoft.com/en-us/windows/desktop/sync/wait-functions#alertable-wait-functions) to block while waiting for an APC to fire.

Waitable timers integrate with the wait functions by signaling a `HANDLE` and optionally by posting an APC.

The quit message could be implemented in a couple of ways: You could either use an event object that `ProcessQueuedMessages` waits on via `WaitForSingleObjectEx` or `WaitForMultipleObjectsEx`, or you could just enqueue a special APC that signals that it is time for the thread to break out of its event loop. Which one you choose probably depends on whether or not you want the event queue to be drained prior to quitting.

Back to Bug 1395259 Comment 11