Let lock function be pluggable.

Allows for more involved locking methods, lock cleanup policy,
and disabling locking altogether.