[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[e4-dev] DI and SWT-Event-Thread syncing
|
Hi,
Someone commented on my latest blog asking why it is still needed to
sync with the event thread and it would be possible make the
DI-Framework findout such things automagically.
While it think by default this should not happen (one should keep the
asnc-code as small as possible) I'd imaging this could be handy for
certain situations (e.g. when dealing with the EventBroker) to specify
the injection to happen on a special thread.
So code like this:
-------------8<-------------
@Inject
void eventHandler(@EventTopic("myeventtopic/*") Object data) {
if( parent.getDisplay().getThread() == Thread.currentThread() ) {
_eventHandler(data);
} else {
parent.getDisplay().syncExec(new Runnable() {
public void run() {
_eventHandler(data);
}
});
}
}
private void _eventHandler(Object data) {
// ....
}
-------------8<-------------
Could be written like this:
-------------8<-------------
@Inject
@UISync
void eventHandler(@EventTopic("myeventtopic/*") Object data) {
// ...
}
-------------8<-------------
My question now is would something like this be possible at all?
Naturally this brings up another question. Do we expect changes to the
IEclipseContext only happen in a special thread, else in the worst case
we'll have to guard all our code which deals with UI with a check like
above.
Tom
--
B e s t S o l u t i o n . a t EDV Systemhaus GmbH
------------------------------------------------------------------------
tom schindl geschaeftsfuehrer/CEO
------------------------------------------------------------------------
eduard-bodem-gasse 5/1 A-6020 innsbruck phone ++43 512 935834