Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine join probe #7156

Merged
merged 17 commits into from
Apr 10, 2023
11 changes: 9 additions & 2 deletions dbms/src/Common/PtrHolder.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#pragma once

#include <mutex>
#include <optional>

namespace DB
{
Expand All @@ -26,7 +27,6 @@ class PtrHolder
{
assert(obj_);
std::lock_guard lock(mu);
assert(!obj);
obj = std::move(obj_);
}

Expand All @@ -39,13 +39,20 @@ class PtrHolder
return res;
}

auto operator->()
auto * operator->()
{
std::lock_guard lock(mu);
assert(obj != nullptr);
return obj.get();
}

auto & operator*()
{
std::lock_guard lock(mu);
assert(obj != nullptr);
return *obj.get();
}

private:
std::mutex mu;
Ptr obj;
Expand Down
Loading