|
Re: Display.syncExec & Display.asyncExec [message #75636 is a reply to message #75599] |
Tue, 26 February 2008 22:08 |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
I think your right that the synchronization should be in both cases on
'runnables'. I guess this is caused by a very unlucky typo...
Executing the syncronized runnables directly in the UIThread makes sense
since the code calling Display#syncExcec has to wait till the runnable's
execution has finished. On the contrary the semantic of
Display#asyncExec is to return directly without execution of the
runnable. The calling thread gets not blocked so we don't execute the
code directly.
Ciao
Frank
-----Ursprüngliche Nachricht-----
Von: Stefan Röck [mailto:stefan.roeck@cas.de]
Bereitgestellt: Dienstag, 26. Februar 2008 18:20
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: Display.syncExec & Display.asyncExec
Betreff: Display.syncExec & Display.asyncExec
Hi all,
I wonder if there are other differences between Display.syncExec &
Display.asyncExec beside that the callee thread is blocked in the one
case and in the other isn't?
I took a look at the implementation of UICallBackManager#addAsync and
UICallBackManager#addSync and there are some differences which look
strange.
First: Should't the synchronisation be done on this.runnables in BOTH
cases?
Second: Why does addSync execute the runnable, if called from UI-Thread
and addAsync doesn't?
RAP-Code is below.
Regards,
Stefan.
public void addAsync( final Runnable runnable, final Display display
) {
synchronized( runnables ) {
runnables.add( new RunnableBase( runnable, display ) );
// TODO [fappel]: This may not work properly in case asyncExcec
is
// called in before render of a PhaseListener
if( Thread.currentThread() != display.getThread() ) {
sendUICallBack();
}
}
}
public void addSync( final Runnable runnable, final Display display )
{
synchronized( runnable ) {
if( Thread.currentThread() != display.getThread() ) {
SyncRunnable syncRunnable = new SyncRunnable( runnable, display
);
runnables.add( syncRunnable );
sendUICallBack();
syncRunnable.block();
} else {
runnable.run();
}
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.03217 seconds