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