|
|
Re: [CDO] CDOViews and controlling updates [message #1737529 is a reply to message #1735631] |
Sat, 09 July 2016 08:31 |
|
Hi Simon,
Comments below...
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Am 21.06.2016 um 16:41 schrieb Simon Goodall:
> Hi,
>
> I am integrating CDO into my application to avoid various concurrency issues.
>
> Currently I have a single CDOView open on my model and I create transactions on top of this view
> (session.openTransaction(viewInstance)) when I need to make changes.
>
> I am finding my view is being automatically updated when the transaction commits. This would appear to still be a
> source of concurrency issues i.e. the UI could be refreshing as the view state updates.
Why do you think that this could be a "concurrency issue"? What exact kind of issue? Maybe you could give an example of
such an issue?
>
> As I understand it, iterating over a list should not be a problem with a CDO generated model,
Well, that can be a problem. But what you describe (just "iterating") is a little vague.
If you're really just iterating (and not modify the object or list), you should probably synchronize on the view to
prevent CDO to update the list with remote changes while you're iterating. As of CDO 4.5 the best way to synchronize on
a view is to use one of these methods:
org.eclipse.emf.cdo.view.CDOView.syncExec(Runnable)
org.eclipse.emf.cdo.view.CDOView.syncExec(Callable<V>)
I call it the best way because it transparently allows for advanced synchronization such as considering
Display.syncExec() calls as "in-thread" calls. This is pluggable and it's implemented for example in
org.eclipse.net4j.util.concurrent.DelegableReentrantLock .
Of course, if you base accumalate calculations on the list iteration (such as sums or likewise), you probably want to
prevent other transactions from modifying the list and its elements. Acquire (at least) read locks on all elements
involved in the calculation and let them be released when you comit the result of the calculation.
Before I expand on your ideas to disable automatic updates, I'd like to hear what you think about the above ;-)
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
> but the model state could still be inconsistent as the view is updated.
> Is my understanding correct? Can anybody comment on the best way to handle this situation? I am thinking I need to
> disable automatic view updates (can this be done on a per view basis - I have seen the passive updates option at the
> session level) and manually refresh on the UI thread. I am not sure how to find out when the model view is invalid.
>
> Another question I have - how are transient fields handled? Presumably they are local only to the instance in the
> view/transaction?
>
> Thanks,
>
> Simon
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Powered by
FUDForum. Page generated in 0.03095 seconds