aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/threading/atomic/bool.h
blob: 13b5e5356afed1f35e0e3582f2e7abc38493a667 (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
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once

#include <util/system/atomic.h> 

namespace NAtomic { 
    class TBool { 
    public: 
        TBool() noexcept = default; 

        TBool(bool val) noexcept 
            : Val_(val) 
        { 
        } 
 
        TBool(const TBool& src) noexcept {
            AtomicSet(Val_, AtomicGet(src.Val_));
        }

        operator bool() const noexcept { 
            return AtomicGet(Val_); 
        } 
 
        const TBool& operator=(bool val) noexcept {
            AtomicSet(Val_, val); 
            return *this; 
        } 
 
        const TBool& operator=(const TBool& src) noexcept {
            AtomicSet(Val_, AtomicGet(src.Val_)); 
            return *this; 
        } 
 
    private: 
        TAtomic Val_ = 0; 
    }; 
}