2018-05-21 13:49:54 +00:00
|
|
|
#include "ActionLock.h"
|
|
|
|
#include <Common/ActionBlocker.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
ActionLock::ActionLock(const ActionBlocker & blocker) : counter_ptr(blocker.counter)
|
|
|
|
{
|
|
|
|
if (auto counter = counter_ptr.lock())
|
|
|
|
++(*counter);
|
|
|
|
}
|
|
|
|
|
2022-02-25 19:04:48 +00:00
|
|
|
ActionLock::ActionLock(ActionLock && other) noexcept
|
2018-05-21 13:49:54 +00:00
|
|
|
{
|
|
|
|
*this = std::move(other);
|
|
|
|
}
|
|
|
|
|
2022-02-25 19:04:48 +00:00
|
|
|
ActionLock & ActionLock::operator=(ActionLock && other) noexcept
|
2018-05-21 13:49:54 +00:00
|
|
|
{
|
|
|
|
auto lock_lhs = this->counter_ptr.lock();
|
|
|
|
|
|
|
|
counter_ptr = std::move(other.counter_ptr);
|
|
|
|
/// After move other.counter_ptr still points to counter, reset it explicitly
|
|
|
|
other.counter_ptr.reset();
|
|
|
|
|
|
|
|
if (lock_lhs)
|
|
|
|
--(*lock_lhs);
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|