C++ Logo


Advanced search

[std-proposals] unique_lock<atomic_flag>

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Wed, 22 Feb 2023 00:02:11 +0000
I think 'lock_guard' and 'unique_lock' should be usable with atomic_flag.

The constructor would do:

    while ( f.test_and_set() ) f.wait(true);

And the destructor would do:


Furthermore, 'try_lock' would simply be:

    return false == f.test_and_set();

Also defer_lock, adopt_lock and try_to_lock would be easily
implementable as constructor arguments.

Received on 2023-02-22 00:02:23