On 02/22/2013 09:45 AM, Scott Marlow wrote:
One alternative solution, might be to create a top level container
level
queue that the background thread Synchronization.afterCompletion defers
processing to. As soon as the application thread returns control to the
top level, the queue is processed in FIFO order.
One concern that I have about this alternative is that any
synchronizations that depend on (or are depended on) being invoked in a
particular order, would have to run with their respective groups (either
all in the background thread or all in the application thread).
For example, if sync-1, sync-2, sync-3, sync-4 are invoked in respective
order in the background thread and they each depend on the {1,2,3,4}
ordering. If sync-1 + sync-4 are put into the application thread queue
to run from there, we would have two threads (possibly concurrently)
running the synchronizations in the wrong order:
Background thread runs syncs in order:
sync-2, sync-3
Application thread runs syncs in order:
sync-1, synch-4
This is not horrible as long as the two groups of syncs have no
interdependencies but would be bad if there are unknown dependencies.