Issue Details (XML | Word | Printable)

Key: GUMTREE-30
Type: Task Task
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Tony Lam
Reporter: Tony Lam
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
GumTree

Proper concurrency support for observer pattern in object

Created: 20/Mar/07 01:08 AM   Updated: 15/Dec/09 05:29 PM   Resolved: 20/Mar/07 01:19 AM
Return to search
Component/s: platform
Affects Version/s: 1.0.0
Fix Version/s: 0.1.0

Time Tracking:
Not Specified


 Description  « Hide

In observer pattern (aka listener mechanism), the listener list may suffer concurrent access problem (if the application tries to read/call and write/add/remove concurrently).

There are three solutions in Eclipse to handle concurrent :

SWT: Uses its own EventTable to handle array copy to avoid
OSGi: Uses the Event Manager framework. The event manager also handle event dispatch
Eclipse Platform: Uses the ListenerList + EventManager. The event manager adds efficient resource handling on listener lister, without no dispatching abaility.

Since OSGi approach also provide the execution function, the choice of our strategy should also consider this.

Eclipse has four ways in executing unit of code:

SWT: Display sync execute
OSGi: Event Manager with event dispatch
Eclipse Platform: SafeRunner is used to execute runnable in an exception handled way
Eclipse Job API: concurrency + progross monitor support

It seems the event manager from OSGi is more difficult to code against, and is not multi-threaded. Also there is no way to get notification if an event has been dispatched. SafeRunner is also a problem because it is single threaded.

The choice of execution goes to Job API. It also provide notification and delay operation on the job for execution. Now, the problem is either running each listener as job or run all listener under the same job. Base on the benchmark, the former takes about 5-15ms to run 10 simple listeners, and the later one takes 6-16ms to run 10 listeners. So there is no significant performance hints on both approaches.

The final choice for us is ListenerList + Generified EventManager + Job API.



Tony Lam added a comment - 20/Mar/07 01:19 AM

New infrastructure is available on org.gumtree.core


Tony Lam made changes - 20/Mar/07 01:19 AM
Field Original Value New Value
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Tony Lam made changes - 03/Apr/07 11:12 PM
Affects Version/s 1.0.0 [ 13161 ]
Fix Version/s 1.0.0M1 [ 13370 ]
Tony Lam made changes - 15/Dec/09 05:29 PM
Status Resolved [ 5 ] Closed [ 6 ]