aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/local_tasks.h
blob: 4a07bf95f5f415675f2c2a91fb1b8a7c493af9ea (plain) (blame)
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; 
    } 
};