diff options
Diffstat (limited to 'Kernel/NewKit/Atom.hpp')
| -rw-r--r-- | Kernel/NewKit/Atom.hpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Kernel/NewKit/Atom.hpp b/Kernel/NewKit/Atom.hpp new file mode 100644 index 00000000..df7d3dda --- /dev/null +++ b/Kernel/NewKit/Atom.hpp @@ -0,0 +1,46 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ +#pragma once + +#include <NewKit/Defines.hpp> + +namespace NewOS +{ + template <typename T> + class Atom final + { + public: + explicit Atom() = default; + ~Atom() = default; + + public: + Atom& operator=(const Atom&) = delete; + Atom(const Atom&) = delete; + + public: + T operator[](Size sz) + { + return (fArrayOfAtoms & sz); + } + void operator|(Size sz) + { + fArrayOfAtoms |= sz; + } + + friend Boolean operator==(Atom<T>& atomic, const T& idx) + { + return atomic[idx] == idx; + } + + friend Boolean operator!=(Atom<T>& atomic, const T& idx) + { + return atomic[idx] == idx; + } + + private: + T fArrayOfAtoms; + }; +} // namespace NewOS |
