mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-10 19:32:10 +00:00
Apply some refactoring/cleanup to mainly util functions
This commit is contained in:
parent
89e3bc8d56
commit
e73eed247e
19 changed files with 190 additions and 160 deletions
|
@ -18,6 +18,9 @@ public:
|
|||
MutexedVariable(const T &value):
|
||||
m_value(value)
|
||||
{}
|
||||
MutexedVariable(T &&value):
|
||||
m_value(std::move(value))
|
||||
{}
|
||||
|
||||
T get()
|
||||
{
|
||||
|
@ -31,9 +34,14 @@ public:
|
|||
m_value = value;
|
||||
}
|
||||
|
||||
// You pretty surely want to grab the lock when accessing this
|
||||
T m_value;
|
||||
void set(T &&value)
|
||||
{
|
||||
MutexAutoLock lock(m_mutex);
|
||||
m_value = std::move(value);
|
||||
}
|
||||
|
||||
private:
|
||||
T m_value;
|
||||
std::mutex m_mutex;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue