Add object trylock

This PR adds two functions to try-lock objects.
Targets issue #117.