Refactored TwitchChannel
This commit is contained in:
@@ -21,16 +21,31 @@ public:
|
||||
this->mutex_.unlock();
|
||||
}
|
||||
|
||||
T *operator->() const
|
||||
const T *operator->() const
|
||||
{
|
||||
return &this->element_;
|
||||
}
|
||||
|
||||
T &operator*() const
|
||||
T *operator->()
|
||||
{
|
||||
return &this->element_;
|
||||
}
|
||||
|
||||
const T &operator*() const
|
||||
{
|
||||
return this->element_;
|
||||
}
|
||||
|
||||
T &operator*()
|
||||
{
|
||||
return this->element_;
|
||||
}
|
||||
|
||||
T clone() const
|
||||
{
|
||||
return T(this->element_);
|
||||
}
|
||||
|
||||
private:
|
||||
T &element_;
|
||||
std::mutex &mutex_;
|
||||
@@ -40,7 +55,7 @@ template <typename T>
|
||||
class UniqueAccess
|
||||
{
|
||||
public:
|
||||
template <typename std::enable_if<std::is_default_constructible<T>::value>::type * = 0>
|
||||
template <typename X = decltype(T())>
|
||||
UniqueAccess()
|
||||
: element_(T())
|
||||
{
|
||||
@@ -73,9 +88,14 @@ public:
|
||||
return AccessGuard<T>(this->element_, this->mutex_);
|
||||
}
|
||||
|
||||
const AccessGuard<T> access() const
|
||||
{
|
||||
return AccessGuard<T>(this->element_, this->mutex_);
|
||||
}
|
||||
|
||||
private:
|
||||
T element_;
|
||||
std::mutex mutex_;
|
||||
mutable T element_;
|
||||
mutable std::mutex mutex_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
@@ -1 +0,0 @@
|
||||
#include "uniqueaccess.hpp"
|
||||
Reference in New Issue
Block a user