mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
The use has been removed from the following files: * Atomic.hpp * SignalVector.hpp * Benchmark.hpp * IvrApi * LoggingChannel.hpp * Singleton.hpp * Image.hpp * PrecompiledHeader.hpp * Message.hpp * MessageElement.hpp * MessageLayout.hpp * MessageLayoutElement.hpp * Fonts.hpp (just include)
50 lines
804 B
C++
50 lines
804 B
C++
#pragma once
|
|
|
|
#include <mutex>
|
|
|
|
namespace chatterino {
|
|
|
|
template <typename T>
|
|
class Atomic
|
|
{
|
|
public:
|
|
Atomic() = default;
|
|
|
|
Atomic(T &&val)
|
|
: value_(val)
|
|
{
|
|
}
|
|
|
|
Atomic(const Atomic &) = delete;
|
|
Atomic &operator=(const Atomic &) = delete;
|
|
|
|
Atomic(Atomic &&) = delete;
|
|
Atomic &operator=(Atomic &&) = delete;
|
|
|
|
T get() const
|
|
{
|
|
std::lock_guard<std::mutex> guard(this->mutex_);
|
|
|
|
return this->value_;
|
|
}
|
|
|
|
void set(const T &val)
|
|
{
|
|
std::lock_guard<std::mutex> guard(this->mutex_);
|
|
|
|
this->value_ = val;
|
|
}
|
|
|
|
void set(T &&val)
|
|
{
|
|
std::lock_guard<std::mutex> guard(this->mutex_);
|
|
|
|
this->value_ = std::move(val);
|
|
}
|
|
|
|
private:
|
|
mutable std::mutex mutex_;
|
|
T value_;
|
|
};
|
|
|
|
} // namespace chatterino
|