HPCC-11966 Extend locking primitives to add assertLocked()

Handle nested case in linux too

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