Implement locking with `lockfile`.

This depends on the changes in broccoli PR #141.