mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Compare commits
3 commits
4c5c71e0c6
...
89a7052a94
Author | SHA1 | Date | |
---|---|---|---|
89a7052a94 | |||
c98a0cf460 | |||
5cd4c51f07 |
|
@ -26,7 +26,7 @@
|
|||
- Minor: Normalized the input padding between light & dark themes. (#5095)
|
||||
- Minor: Add `--activate <channel>` (or `-a`) command line option to activate or add a Twitch channel. (#5111)
|
||||
- Minor: Chatters from recent-messages are now added to autocompletion. (#5116)
|
||||
- Minor: Add support for input.text in commands run with hotkeys. (#5130)
|
||||
- Minor: Added support for the `{input.text}` placeholder in the **Split** -> **Run a command** hotkey. (#5130)
|
||||
- Bugfix: Fixed an issue where certain emojis did not send to Twitch chat correctly. (#4840)
|
||||
- Bugfix: Fixed capitalized channel names in log inclusion list not being logged. (#4848)
|
||||
- Bugfix: Trimmed custom streamlink paths on all platforms making sure you don't accidentally add spaces at the beginning or end of its path. (#4834)
|
||||
|
@ -134,6 +134,7 @@
|
|||
- Dev: Added benchmark for parsing and building recent messages. (#5071)
|
||||
- Dev: Boost is depended on as a header-only library when using conan. (#5107)
|
||||
- Dev: Added signal to invalidate paint buffers of channel views without forcing a relayout. (#5123)
|
||||
- Dev: Specialize `Atomic<std::shared_ptr<T>>` if underlying standard library supports it. (#5133)
|
||||
|
||||
## 2.4.6
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
namespace chatterino {
|
||||
|
@ -9,9 +11,10 @@ class Atomic
|
|||
{
|
||||
public:
|
||||
Atomic() = default;
|
||||
~Atomic() = default;
|
||||
|
||||
Atomic(T &&val)
|
||||
: value_(val)
|
||||
: value_(std::move(val))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -47,4 +50,67 @@ private:
|
|||
T value_;
|
||||
};
|
||||
|
||||
#if defined(__cpp_lib_atomic_shared_ptr) && defined(__cpp_concepts)
|
||||
|
||||
template <typename T>
|
||||
class Atomic<std::shared_ptr<T>>
|
||||
{
|
||||
// Atomic<std::shared_ptr<T>> must be instantated with a const T
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
requires std::is_const_v<T>
|
||||
class Atomic<std::shared_ptr<T>>
|
||||
{
|
||||
public:
|
||||
Atomic() = default;
|
||||
~Atomic() = default;
|
||||
|
||||
Atomic(T &&val)
|
||||
: value_(std::make_shared<T>(std::move(val)))
|
||||
{
|
||||
}
|
||||
|
||||
Atomic(std::shared_ptr<T> &&val)
|
||||
: value_(std::move(val))
|
||||
{
|
||||
}
|
||||
|
||||
Atomic(const Atomic &) = delete;
|
||||
Atomic &operator=(const Atomic &) = delete;
|
||||
|
||||
Atomic(Atomic &&) = delete;
|
||||
Atomic &operator=(Atomic &&) = delete;
|
||||
|
||||
std::shared_ptr<T> get() const
|
||||
{
|
||||
return this->value_.load();
|
||||
}
|
||||
|
||||
void set(const T &val)
|
||||
{
|
||||
this->value_.store(std::make_shared<T>(val));
|
||||
}
|
||||
|
||||
void set(T &&val)
|
||||
{
|
||||
this->value_.store(std::make_shared<T>(std::move(val)));
|
||||
}
|
||||
|
||||
void set(const std::shared_ptr<T> &val)
|
||||
{
|
||||
this->value_.store(val);
|
||||
}
|
||||
|
||||
void set(std::shared_ptr<T> &&val)
|
||||
{
|
||||
this->value_.store(std::move(val));
|
||||
}
|
||||
|
||||
private:
|
||||
std::atomic<std::shared_ptr<T>> value_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
Loading…
Reference in a new issue