aboutsummaryrefslogblamecommitdiffstats
path: root/library/cpp/threading/atomic/bool.h
blob: 6e336280ed5dd74e87c515b3f2590e5612fc7e97 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
            
                                                 









                                   


                                                 


                                        
                                                   


                                 
                                                           





                                                 
 
#pragma once

#include <library/cpp/deprecated/atomic/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;
    };
}