[previous] [up] [next]     [contents] [index]
Next: Creating and Setting the Up: Eventspaces Previous: Eventspaces

Eventspaces and Threads

When an event is dequeued for a particular eventspace, a handler thread is created to handle the event. Once the thread terminates, another event is dequeued and a new handler thread is created to handle the new event.[footnote] A handler thread can spawn other threads that run simultaneously with the handler thread(s). Non-handler threads may run indefinitely and they do not block event handling.

Certain situations require nested-event handling, such as processing a modal dialog or calling wx:yield. When a handler thread is blocked by a nested event loop in its own eventspace, the handler thread is used to handle the nested events (like a nested procedure call). When a non-handler thread is blocked by a nested event loop (i.e., the thread is not a handler thread, or the thread is a handler thread for a different eventspace), then the blocked thread continues to be blocked until events can be serviced (as normal or nested events) from a different thread. For example, if a spawned thread causes a modal dialog to be shown, the spawned thread will block until the dialog is hidden; meanwhile, events for the modal dialog are handled by other (newly created) handler threads.



PLT