I am trying to implement Test and Test-and-set in c++.
as per C++ atomic_flag query state we cannot check the flag state, so whats the workaround for that
loop will be like this
std::atomic_flag lock_stream = ATOMIC_FLAG_INIT;
void ttas_lock()
{
while(lock_Stream);
while(lock_stream.test_and_set());
return
}
error: could not convert ‘((ttas*)this)->ttas::lock_stream’ from ‘std::atomic_flag’ to ‘bool’ while(lock_stream)