Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[rap-dev] ModalContext

Hello

It seems that the ModalContext functionality should be reimplemented on RAP
(it is ported from RCP now).

First remark: look at the
org.eclipse.jface.operation.ModalContext.ModalContextThread.run(). There is
a call: "display.asyncExec(null);". On RCP such call have a special meaning.
This call causes display thread to wake up.

Maybe this call ("display.asyncExec(null);") should be removed from the
org.eclipse.jface.operation.ModalContext.ModalContextThread.run() ?
Alternative maybe Display#asyncExec should be reimplemented (and also
syncExec) for the case where runnable is null?

Second remark:

There is another part of code in the
org.eclipse.jface.operation.ModalContext.ModalContextThread.run():

display.syncExec(new Runnable() {
  public void run() {
    // do nothing
  }
});

On RAP this code causes deadlocks with
org.eclipse.jface.operation.ModalContext.ModalContextThread.block() method.
Moreover, there is a problem with
org.eclipse.rwt.internal.lifecycle.UICallBackManager.SyncRunnable and
ModalContext. As you know, SyncRunnable has a block() method, wich blocks
the thread that called
org.eclipse.rwt.internal.lifecycle.UICallBackManager.addSync(Display,
Runnable) method. The blocked thread will wait on special lock object until
the notification from other thread (with should call SyncRunnable#run
method). But when you are using ModalContext the other thread will blocked
on runnablesLock.

I think the problem in the
org.eclipse.rwt.internal.lifecycle.UICallBackManager.addSync(Display,
Runnable) method.

Third remark:

// Make sure that all events in the asynchronous event queue
// are dispatched.
display.syncExec(new Runnable() {
  public void run() {
    // do nothing
  }
});

This code do not the things that declared in comments.

Last remark: "display.asyncExec(null);" can be implemented correctly, but
you have to place additional synchronization string in
org.eclipse.jface.operation.ModalContext.ModalContextThread.run() to prevent
ending of execution
org.eclipse.jface.operation.ModalContext.ModalContextThread.run() before
display.sleep() occures in
org.eclipse.jface.operation.ModalContext.ModalContextThread.block() method.

Place

synchronized (display.getThread()) {
}

before 

// Stop event dispatching
continueEventDispatching = false;

The display.getThread() returns UIThread instance. So it will be locked
until the switchThread notification from display.sleap() method.

Thank you, Igor




Back to the top