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