atomic_atomic_flag_notify_all
atomic_atomic_flag_notify_all (원자적 플래그 알림)
std::atomic_flag_notify_all는 std::atomic_flag에서 대기 중인 모든 스레드를 깨워요.
출처: cppreference
본문
std::atomic_flag_notify_all은 <atomic> 헤더에 정의된 자유 함수예요. C++20부터 사용 가능해요.
void atomic_flag_notify_all( std::atomic_flag* flag ) noexcept;
flag->notify_all()처럼 동작해요. flag에서 atomic_flag_wait로 대기 중인 모든 스레드를 깨워요. 값이 변경되었을 때 알리는 용도로 써요.
예제 (Example)
#include <atomic>
#include <thread>
std::atomic_flag flag;
int main()
{
std::thread t([&]{ std::atomic_flag_wait(&flag, false);
/* 깨어난 후 작업 */ }).detach();
std::atomic_flag_clear(&flag);
std::atomic_flag_notify_all(&flag);
}