Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Display.syncExec & Display.asyncExec
Display.syncExec & Display.asyncExec [message #75599] Tue, 26 February 2008 17:20 Go to next message
Stefan   is currently offline Stefan Friend
Messages: 316
Registered: July 2009
Senior Member
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();
}
}
}
Re: Display.syncExec & Display.asyncExec [message #75636 is a reply to message #75599] Tue, 26 February 2008 22:08 Go to previous message
Eclipse UserFriend
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();
}
}
}
Previous Topic:Drag and Drop support - JFACE LocalSelectionTransfer
Next Topic:Change statusLine showing information
Goto Forum:
  


Current Time: Sat Apr 20 01:08:11 GMT 2024

Powered by FUDForum. Page generated in 0.03217 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top