blob: 1ae54ff9ff20566333014cb46fb8abab34dd8c61 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#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);
}
ActionLock::ActionLock(ActionLock && other) noexcept
{
*this = std::move(other);
}
ActionLock & ActionLock::operator=(ActionLock && other) noexcept
{
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;
}
}
|