From e9d85c9ba5720059e0b7a6eff562af3f535c7b1d Mon Sep 17 00:00:00 2001 From: Tishj Date: Sat, 21 Oct 2023 13:28:02 +0200 Subject: [PATCH] formatting --- src/include/duckdb/main/client_context.hpp | 6 +++++- src/main/client_context.cpp | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/include/duckdb/main/client_context.hpp b/src/include/duckdb/main/client_context.hpp index 46704bb488ef..71b30bacdf69 100644 --- a/src/include/duckdb/main/client_context.hpp +++ b/src/include/duckdb/main/client_context.hpp @@ -274,16 +274,20 @@ class ClientContextLock { private: // The identifier for an invalid thread static const std::thread::id INVALID_THREAD; + private: - explicit ClientContextLock(mutex &context_lock, atomic &marker) : client_guard(context_lock), marker(marker) { + explicit ClientContextLock(mutex &context_lock, atomic &marker) + : client_guard(context_lock), marker(marker) { // Set the current thread so lock attempts by the same thread don't result in a deadlock marker = std::this_thread::get_id(); } + public: ~ClientContextLock() { // Unset the current thread before unlocking the client_guard marker = INVALID_THREAD; } + public: static unique_ptr Lock(ClientContext &context) { auto can_lock = context.context_lock.try_lock(); diff --git a/src/main/client_context.cpp b/src/main/client_context.cpp index 7b242d83bca0..af9607ce3ed1 100644 --- a/src/main/client_context.cpp +++ b/src/main/client_context.cpp @@ -60,7 +60,8 @@ struct ActiveQueryContext { }; ClientContext::ClientContext(shared_ptr database) - : db(std::move(database)), interrupted(false), client_data(make_uniq(*this)), transaction(*this), thread_id(std::thread::id()) { + : db(std::move(database)), interrupted(false), client_data(make_uniq(*this)), transaction(*this), + thread_id(std::thread::id()) { } ClientContext::~ClientContext() {