I'm getting back to Clojure after an extended absence. Just today I
was pondering the design of a solution to a similar problem, though I
suspect our requirements diverge on several points. My tentative
conclusion was that it could be done entirely in Clojure and without
modifying existing code. Maybe you can poke holes in my fledging plan
since you've obviously been thinking about this sort of problem longer
than me:
There's a new pref reference type. It consists of a key and an atom
containing nil for unloaded objects and an STM reference for loaded
objects.
When a pref is dereferenced, it checks its atom. If nil, it first
loads the object from disk into a fresh STM reference (which has a
metadata field pointing back to the pref) and mutates the atom so it
points to it. In either case it finishes by dereferencing the STM
reference.
When a pref is mutated, it first goes through the same motions as for
dereferencing. Then it simply forwards the mutation to the underlying
STM reference.
Watchers are installed on STM references backed by prefs. Thus we are
notified when something is mutated.
There is a pref-specific transaction boundary form called atomic,
analogous to dosync. The watchers are used to determine which prefs
were mutated during the transaction so as to flag them dirty for
write-back or write-through caching; this is why we need the pref back
reference in the metadata.
Anyway, even assuming this all works, it will obviously be less
computationally efficient than extending LockingTransaction.java with
special support.
-Per
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
I had the chance to read your code today. You have a transaction
boundary in DRef.set() which is called by LockingTransaction.run() at
commit time. My point was that if you weren't intrusively modifying
LockingTransaction.java you would need to take care of that somewhere
else, the most obvious place being a dosync wrapper form. All you
would need is a seq of 'vals' returned on a commited run(). That would
also be useful for application-side transaction logging, etc.
-Per
-Per