Consider what happens when two threads A and B simultaneously want to
make updates to a shared data structure S.
If immutable update techniques are used, each thread will create a
copy of S with their own changes only, ie S_A and S_B.
But how to see the impact of both updates together, S_AB?
Either:
- A and B have to serialize their changes, in which case we don't have
any write concurrency
- A mutable structure is used that can be updated at multiple points at once.
Generally data structures supporting concurrent writes are mutable.
But this brings it own challenges: traversing over a structure
undergoing modification is a nightmare.
So the current state of the art are "snapshot-able" structures, which
can flip-flop between mutable and immutable modes. When flipped into
immutable mode, they can leave behind an immutable snapshot of their
state for readers to work off, then flip back to mutable mode and
continue to mutate in parallel.
The price of the snapshot is a brief throttling back of write
activity, to allow the structure to stabilise enough to form a
consistent snapshot, and one copy-on-write whenever a node diverges
from the last snapshotted state.
-Ben
> --
> You received this message because you are subscribed to the Google Groups "Melbourne Scala User Group" group.
> To post to this group, send an email to
scala...@googlegroups.com.
> To unsubscribe from this group, send email to
scala-melb+...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/scala-melb?hl=en-GB.
>