Running into Deadlocks using EMF Transaction API? [message #31238] |
Wed, 12 April 2006 22:43 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi,
If you have been running into deadlocks where multiple threads communicating
synchronously need to access the same editing domain for reading or for
writing, I have committed a bit of new API for this week's M6a build which
may help.
The new TransactionalEditingDomain method
RunnableWithResult createPrivilegedRunnable(Runnable)
allows a thread that owns a transaction to "bless" a Runnable, so that it
may be executed on any other thread while the currently active transaction
is in progress. The thread that executes the resulting privileged runnable
"borrows" the transaction for the duration of the execution.
This allows multiple threads to cooperatively share transactions, as long as
they synchronize themselves appropriately to avoid protocol violations.
Note that, while a privileged runnable is executing one one thread, the
thread that originally owned the transaction has lost access to the editing
domain for the duration, because it temporarily gave up ownership.
A privileged runnable can borrow read-only and read-write transactions,
alike.
A common source of grief is the need for a background thread (such as a
modal context thread), which has an open transaction, needing to call some
other API on the UI thread via Display.syncExec(). When that syncExec'd
code needs a transaction to access the editing domain, deadlock ensues.
Passing a privileged runnable to an API such as Display.syncExec() can
help.
This changed is tracked by
https://bugs.eclipse.org/bugs/show_bug.cgi?id=136156.
Cheers,
Christian
|
|
|
Powered by
FUDForum. Page generated in 0.03280 seconds