ztellman/lamina — pull request #45 by DerGuteMoritz (2012-09-27 12:07:00+00:00)
Title: Properly release locks in `lamina.core.graph.node/propagate`

Previously, exceptions raised in `lamina.core.graph.node/propagate`
could lead to a node's lock to not be released properly because
releasing didn't happen in a `finally` clause. However, using the
`with-lock` macro is not possible in this case because in some
branches the lock is released before the `with-lock` body ends. To
allow for this, a `with-lock*` macro is introduced. If the lock is
released inside its body it will refrain from unlocking it again. To
support this, `locked?` is added to `ILock` which checks whether a
lock is currently held. Also, recurring from inside a `try` form is
not allowed but would be required in this case for traversing a chain
of nodes. Thus the nodes traversal loop is changed to recur from
outside the `try` form.

I'm not sure if this is the best way to fix the root problem, so feel
free to implement a better solution instead.

Oh, and I threw out some unnecessary `do` forms from `with-lock`
and `with-exclusive-lock` while I was at it :-)