Bug 213629 - [flex] Flexible hierarchy provider interfaces should specify that they will be invoked on the UI thread.
Summary: [flex] Flexible hierarchy provider interfaces should specify that they will b...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.4   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.8 M4   Edit
Assignee: Pawel Piech CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2007-12-20 14:53 EST by Pawel Piech CLA
Modified: 2012-01-25 13:28 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pawel Piech CLA 2007-12-20 14:53:04 EST
I'm filing this bug as a result of discussion in bug 199915.

I believe that the flexible hierarchy APIs would be easier and safer to implement if they were guaranteed to be invoked only on the UI thread.  Currently this is already mostly the case, however since the interface definitions do not specify this, the implementers of these interfaces must assume that they need to be thread safe.

As part of this request, I think IPresentationContext should have a new method:
    Display getDisplay();
This would provide easy access by the implementers to the Display object and thread.
Comment 1 Darin Wright CLA 2007-12-20 14:58:51 EST
Actually, this is not the case. A provider can be called in a non-UI thread in response to an event from a model proxy. I.e. A model proxy triggers updates in the thread that the model proxy reports deltas in. I'm not sure we want/need to change this for 3.4.
Comment 2 Pawel Piech CLA 2007-12-20 16:29:37 EST
I'm sorry, I should have been more clear that this is an item for consideration past 3.4.  I agree that it's too late to rock the boat on these APIs in 3.4.

(In reply to comment #1)
> Actually, this is not the case. A provider can be called in a non-UI thread in
> response to an event from a model proxy. I.e. A model proxy triggers updates in
> the thread that the model proxy reports deltas in.

As part of this request, I think we should also consider making it mandatory that IModelProxyListeners be called on the UI thread, and that the viewer process the delta within the same dispatch (i.e. without using a WorkbenchJob as it does now).  This would allow the model proxy to more accurately predict the state of the viewer in order to prevent race conditions in the proxy itself.  

I ran into this problem recently when fixing bugs related to a cache maintained in DSF's IElementContentProvider/IModelProxy implementation.  In order for the cache to be synchronized with the viewer, in certain situations it needs to be reset at the same time as when the view contents are refreshed.  However, since the viewer's model proxy listener schedules a job to process the proxy, there is a small window of time when the cache could be corrupted with stale data.  Still, I think such API changes need time to be considered, and I'm willing to live with this theoretical race condition through 3.4.

Comment 3 Darin Wright CLA 2008-01-03 10:28:03 EST
Marking assigned for future consideration
Comment 4 Pawel Piech CLA 2012-01-25 13:28:11 EST
After the flex viewer refactoring, we now have IModelProxy2 interface which has an initialize() method called on the UI thread.  I also changed the viewer's delta listener implementation to process the deltas immediately if received on the UI thread.