<AWT Dev>  Review Request JDK-6980209: Make tracking SecondaryLoop.enter/exit methods easier
semyon.sadetsky at oracle.com
Thu Mar 26 14:49:43 UTC 2015
Please review fix for JDK9.
***The root cause:
There are 2 issues in WaitDispatchSupport:
1. If exit() is called before the secondary loop just silently never
ends. That is pointed in the summary.
2. In the same spec it is proposed to call exit() and enter()
concurrently but they are not thread-safe. That is an additional issue.
To fix 1: I support Artem's proposal for enter() to return false
immidiately in case if disordered exit() detected.
To fix 2: WaitDispatchSupport need to be reworked to allow concurrent
execution. Unfortunately we cannot synchronize EDT with another thread,
so the secondary loop launching cannot be run atomically. And this is
very sensitive area because of potential possibility to block EDT. Right
testing of the fix is very desirable.
1. User immediately get false as result of enter() if it is detected
that exit() has been run either before or concurrently. For that purpose
a new AtomicBoolean field prematureExit is introduced.
2. The exit() and enter() are reworked to be capable to run concurrently
and avoid EDT jam in the secondary loop. See comments to the code for
Test launches the secondary loop upon a button press action triggered by
the Robot and simultaneously call exit() in a separate thread. The Robot
sends a big number of events (number is adjustable by ATTEMPTS constant)
to cover different concurrent states randomly. Along with that the Robot
sends a number of key events to ensure that UI is kept responsive and
all events are dispatched by EDT. The number of the sent key events is
tested to be equal to the number of processed events.
The test is run in different modes to test secondary loop launching from
EDT and non-EDT threads.
More information about the awt-dev