1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#pragma once #include <util/system/atomic.h> class TLocalTasks { private: TAtomic GotTasks; public: TLocalTasks() : GotTasks(0) { } void AddTask() { AtomicSet(GotTasks, 1); } bool FetchTask() { bool gotTasks = AtomicCas(&GotTasks, 0, 1); return gotTasks; } };