Community
Participate
Working Groups
I've noticed a strange behavior using the UIJob on Eclipse 4.2 (Build id: 20120614-1722) with RAP 1.5. There are multiple jobs containing the same SchedulingRule marking the jobs as conflicting, therefore only one job is executed at the same time. After a few jobs are executed the execution stops even though there are waiting jobs left. I've enabled tracing and added a JobChangeListener to the JobManager logging the scheduling process. 14:06:09.377-[Thread[UIThread [propvt9tkkc7vn1v903t09dx],6,main]]Scheduling job: Job(13) 18561 [UIThread [propvt9tkkc7vn1v903t09dx]] DEBUG MapView - scheduled Job(13) 18561 [Worker-1] DEBUG MapView - aboutToRun Job(12) 18561 [Worker-1] DEBUG MapView - running Job(12) 14:06:09.378-[Thread[Worker-0,5,main]]worker sleeping for: 60000ms 14:06:09.378-[Thread[Worker-1,5,main]]worker sleeping for: 60000ms 18562 [UIThread [propvt9tkkc7vn1v903t09dx]] DEBUG MapView - execute Job(12) 18634 [UIThread [propvt9tkkc7vn1v903t09dx]] DEBUG MapView - Job(12) finished after 72 ms 14:06:09.450-[Thread[UIThread [propvt9tkkc7vn1v903t09dx],6,main]]Ending job: Job(12) 18634 [UIThread [propvt9tkkc7vn1v903t09dx]] DEBUG MapView - done Job(12) 14:06:09.450-[Thread[Worker-0,5,main]]Starting job: Job(13) 18634 [Worker-0] DEBUG MapView - aboutToRun Job(13) 18635 [Worker-0] DEBUG MapView - running Job(13) 14:06:09.451-[Thread[Worker-0,5,main]]worker sleeping for: 60000ms 14:07:09.377-[Thread[Worker-1,5,main]]worker sleeping for: 60000ms 14:07:09.450-[Thread[Worker-0,5,main]]worker sleeping for: 60000ms The JobChangeListener is notified that the job is running but the runInUIThread method of the job isn't executed (The first command in the method is the "execute Job" log message). After an arbitrary ui event occurs the job is executed successfully. ---ui event--- 112822 [UIThread [propvt9tkkc7vn1v903t09dx]] DEBUG MapView - execute Job(13) 112952 [UIThread [propvt9tkkc7vn1v903t09dx]] DEBUG MapView - Job(13) finished after 129 ms 14:07:43.768-[Thread[UIThread [propvt9tkkc7vn1v903t09dx],6,main]]Ending job: Job(13) 112952 [UIThread [propvt9tkkc7vn1v903t09dx]] DEBUG MapView - done Job(13)
org.eclipse.ui.progress.UIJob runs the contents of the job in a display.asyncExec(*). If there are OS level UI events happening then any newly added asyncExec(*) won't be run ... until the next OS event (key press, mouse move, paint request, etc). PW
Paul, doesn't the UI run the event loop when idle? Or does readAndDispatch not wakeup when deferred events are scheduled?
Bogdan, I was wondering if there's any API for this case: The event loop is completely idle, and someone posts an asyncExec(*). Right now it just goes into the queue until the next OS event wakes up the event loop, but is there a way to post the asyncExec(*) and tell the event loop "wake up and check your queues" PW
There are some limitations regarding using syncExec and asyncExec with RAP. See the last point here: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.rap.help%2Fhelp%2Fhtml%2Frwt%2Fdifferences.html I think that in pure SWT there should be no such problem since the UI thread is waken up to process deferred events (see the implementation of org.eclipse.swt.widgets.Synchronizer.addLast(RunnableLock)).
Moving to the RAP team for comment.
If you reschedule a job from itself or another job it's possible to run in a situation where the request is already processed (finished) when it's time to execute the job. In this case the job will be executed with the next request as you already mentioned. This is a know limitation in RAP. See also comments in bug 266832 after comment #24.