George Russell writes:
> Tom Pledger wrote:
> > For two threads to have access to the same MVar, they must have a
> > common ancestor, right? Could a common ancestor spawn a transaction
> > broker thread? That would be similar to what database management
> > systems do. It'd still be centralised, but wouldn't need to do unsafe
> > IO.
>
> Well, all threads trivially have a common ancestor. But I don't
> see how you can pick a particular ancestor. The flags could easily
> have been passed around in a fairly general fashion along
> polymorphic channels.
Sorry, I didn't make that suggestion very clearly.
The suggestion is that the ancestor act in this order:
1. Create the MVars etc. for communication with the transaction
broker thread.
2. Fork the transaction broker's (initial) thread.
3. Do whatever else the program involves, including forking threads
which will be clients of the transaction broker. If these threads
create their own MVars etc., and need to apply transaction
management to them, they must communicate that need to the
transaction broker. This is analogous to creating a table in a
database, or inserting a row into an existing table: the DBMS
becomes responsible for transaction management.
Regards,
Tom