Locking/synchronization helper functions and classes