Interfaces for:
READ-WRITE with SYNCHRONIZATION and EVENTS
| Why is this different? We specifically have placed the responsibility for being safe on the implementor. Any client code wishing to be kept in the loop can listen to events. |
Story: Working with a user interface to define styles as the screen is being refreshed.
Create |
|
not required |
Read |
|
Readers should listen to events |
Visit |
|
not required |
Write |
|
Recommend many readers / single writer approach |
Thread-safe |
|
Inter-thread communication via events |
Mixed Implementations |
|
|
The GeoTools style interface represents an bad example of this done at an interface level, the Swing Document implementation is a good example where many readers are allowed at a time and a single writer is allowed in at a time.
Mutable Interface
Checklist:
Class javadocs ask implementor to make this threadsafe
Some form of event notification (we used PropertyChangeEvents here - which is a poor fit with Collections)
Mutable Implementation
Notes:
- There are many implementations of List out there on the web that can fire events (choose one don't roll your own as in this example)