Closed Updownquark closed 2 years ago
As part of this, the thread safety mechanisms in the swing classes should be modified to inspect the thread constraint object instead of checking for an instance of Abstract safe observable collection or expressions safety promises. If a structure is unsafe, the flow collect methods should be used to wrap the source.
I decided I'd prefer to leave well enough alone. The active collection works perfectly as-is, and the SafeObservableCollection also works well. To accomplish the new flow methods at the top of this issue would require merging the two, and there would probably be a lot of code that has to be copy-pasted with just slight differences, making a maintenance headache. The additional overhead required to actively collect and then thread-safe and batch separately is not too bad, and it's nice that the two don't have to know about each other.
I've added ObservableCollection.safe(ThreadConstraint, Observable) along with similar methods for Observable, ObservableValue, and SettableValue. I've gone through the swing code and added a lot of thread safety in, though I definitely did not do it exhaustively. All the places that were doing it before are doing it better now, and some that weren't doing it before are now.
I'm content enough with the state of thread safety now to call this done.
Currently, management of threads for ObservableCollections is done using a separate class, SafeObservableCollection, or now UIOptimizedCollection. With the addition of the ThreadConstraint API, I want to do better.
I want to add: CollectionDataFlow.collectActive(Observable<?> until, ThreadConstraint threading) CollectionDataFlow.collectBatched(Observable<?> until) CollectionDataFlow.collectBatched(Observable<?> until, ThreadConstraint threading) Observable.safe(ThreadConstraint threading) ObservableValue.safe(ThreadConstraint threading)
The collectBatched functionality will be very similar to what the UIOptimizedCollection now does, and collectActive() with a thread constraint will work similarly to SafeObservableCollection.