Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 168878

Summary: [api] AbstractTaskContainer classes should store children in ConcurrentHashMap
Product: z_Archived Reporter: Mik Kersten <mik.kersten>
Component: MylynAssignee: Steffen Pingel <steffen.pingel>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2 CC: robert.elves
Version: unspecified   
Target Milestone: 3.0   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
patch
none
mylyn/context/zip none

Description Mik Kersten CLA 2006-12-21 13:00:20 EST
This will avoid problems on concurrent access and modification by giving a "time slice" of the current state of the container when it is accessed.
Comment 1 Eugene Kuleshov CLA 2006-12-21 14:41:03 EST
As I already commented in bug 167402, you can actually use ConcurrentHashMap with single bogus instance as a value. Then map.keySet() will give you instance of the concurrent set.
Comment 2 Steffen Pingel CLA 2008-03-30 04:36:33 EDT
This is related to implementing a scheme for concurrent access to the task list and ensuring consistency of the task list data model:

- The task list is a directed graph of linked AbstractTaskContainter objects. The improve performance the task list needs to guarantee that the graph has no cycles. All modifications to the data model have to be validated and synchronized.
- The tasks framework needs to provide means to lock the task list for modifications and to retrieve consistent snapshots of the task list for saving and export.
Comment 3 Robert Elves CLA 2008-04-05 14:37:58 EDT
Steffen's comment from bug#213228:
	Another spot that needs to be reviewed is the TaskActiviationHistory. It stores tasks in a list and relies on equals() for removing tasks.
Comment 4 Steffen Pingel CLA 2008-04-29 03:02:33 EDT
Created attachment 97913 [details]
patch
Comment 5 Steffen Pingel CLA 2008-04-29 03:02:35 EDT
Created attachment 97914 [details]
mylyn/context/zip
Comment 6 Steffen Pingel CLA 2008-04-29 03:07:35 EDT
I have replaced the CopyOnWriteArraySet with a CopyOnWriteArrayList in AbstractTaskContainer and changed the signature of getChildren() to return a collection. Consistency of the task list data model is now validated in the TaskList class. Using a list instead of set (which uses a list as the backend) should yield a minimal performance gain since the list of children is now only for duplicates once rather instead of twice. I have attached a patch in case we need to revert this change.
Comment 7 Mik Kersten CLA 2008-04-29 04:11:58 EDT
Steffen: there is a benefit to returning a collection because it is the most generic thing to return, but we should consider this decision when doing API review.  We use sets in numerous places in order to make it clear to clients that they will not see duplicates and do not need to check for them, and that there is no promise made about ordering.  Those are properties that could be worth retaining in the API.