A null_mutex is a class that models the Mutex requirement concept syntactically, but does nothing. It is useful for instantiating a template that expects a Mutex, but no mutual exclusion is actually needed for that instance.

// Defined in header <oneapi/tbb/null_mutex.h>

namespace oneapi {
namespace tbb {
    class null_mutex {
        constexpr null_mutex() noexcept;

        null_mutex(const null_mutex&) = delete;
        null_mutex& operator=(const null_mutex&) = delete;

        class scoped_lock;

        void lock();
        bool try_lock();
        void unlock();

        static constexpr bool is_rw_mutex = false;
        static constexpr bool is_recursive_mutex = true;
        static constexpr bool is_fair_mutex = true;
} // namespace tbb
} // namespace oneapi

Member classes#

class scoped_lock#

Corresponding scoped_lock class. See the Mutex requirement.

Member functions#


Constructs unlocked mutex.


Destroys unlocked mutex.

void lock()#

Acquires lock.

bool try_lock()#

Tries acquiring lock (non-blocking).

void unlock()#

Releases the lock.