Documentation Home >> Concepts >> Lockable Concept

In order to meet the requirements of the Lockable concept, a type must support lock(), unlock() and try_lock() member functions with the following signatures and semantics:

struct lockable-type
{
    void lock();
    void unlock();
    bool try_lock();
};
lock() Requirements

For an instance m of a lockable type, the expression m.lock() shall block until a lock can be acquired for the current thread.

try_lock() Requirements

For an instance m of a lockable type, the expression m.try_lock() shall attempt to acquire a lock for the current thread without blocking. The function shall return true if the lock was acquired, false otherwise.

unlock() Requirements

For an instance m of a lockable type, the expression m.unlock() shall release a lock previously acquired by a call to m.lock() or m.try_lock().

See Also