aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/local_tasks.h
blob: f7de96590d1de65b00f8859f95874be64442e992 (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;
    }
};