In Smalltalk images that include a user interface (Common Widgets), the startUp class
(System startUpClass) is responsible for providing a polling loop for the user interface process, an instance of
UIProcess. The
UIProcess sends the message
messageLoop to the startUp class to start the polling loop. The
startUp class,
EsWindowSystemStartUp, implements a simple polling loop similar to the one shown below:
As long as there is any activity in the user interface, the UIProcess will continue to poll for events as quickly as possible. As soon as the activity stops, the
UIProcess becomes inactive and suspends. This enables any other Smalltalk processes that are running at the the same or lower priority than the
UIProcess to execute.
Because sending CwAppContext messageLoop can deactivate the
UIProcess, there must be a mechanism for reactivating it. To support this,
sleep enables an operating-system-specific mechanism that causes the private message
CwAppContext default wake to be sent when new events become available. This
wake method is also sent by all other methods that generate user interface activity, causing the
UIProcess to respond immediately.
As previously mentioned, if there is no user interface activity the UIProcess is deactivated, enabling other Smalltalk processes at the same or lower priority to run. However, if there are no other active processes to run, a system-provided "idle" process is run, which repeatedly sends the
suspendSmalltalk message to the default
CwAppContext:
Note that there is an interaction between the suspendSmalltalk method and the Smalltalk
Delay class. If the idle process runs because a higher priority process has suspended on a
Delay, the system must be reactivated when the
Delay expires. This situation is handled in one of three ways depending on the capabilities of the operating system:
|
•
|
With operating systems where the Delay class uses the same mechanism that suspendSmalltalk uses to detect input activity, the system is reactivated with no further intervention.
|
|
•
|
With operating systems where Delay uses a different mechanism than suspendSmalltalk, but it is possible for a user written application to post a user interface event, this facility is used to reactivate the system.
|
Copyright 2005, 2020 Instantiations, Inc. All rights reserved.