HPCC-11966 Extend locking primitives to add assertLocked()

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>