[feature] add *_lockf version of *_lock functions

These functions take a bool (*)(void *) function instead of just a
bool * variable.  Therefore, it's possible to use more complex
cancelation criteria.

The old functions now translate to these newer functions.

Signed-off-by: Shahbaz Youssefi <ShabbyX@gmail.com>