From a03e9c08aefa1fc9964e31f8ab8f88413bfc1e37 Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Sun, 22 Sep 2024 03:42:21 +0100 Subject: [PATCH] combine finish_write and commit_write to a single function --- include/quill/Logger.h | 3 +-- include/quill/core/BoundedSPSCQueue.h | 9 +++++++++ include/quill/core/UnboundedSPSCQueue.h | 9 +++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/quill/Logger.h b/include/quill/Logger.h index 971560e9..835de546 100644 --- a/include/quill/Logger.h +++ b/include/quill/Logger.h @@ -205,8 +205,7 @@ class LoggerImpl : public detail::LoggerBase "The committed write bytes must be equal to the total_size requested bytes"); #endif - thread_context->get_spsc_queue().finish_write(total_size); - thread_context->get_spsc_queue().commit_write(); + thread_context->get_spsc_queue().finish_and_commit_write(total_size); if constexpr (immediate_flush) { diff --git a/include/quill/core/BoundedSPSCQueue.h b/include/quill/core/BoundedSPSCQueue.h index 4448750b..fed8e951 100644 --- a/include/quill/core/BoundedSPSCQueue.h +++ b/include/quill/core/BoundedSPSCQueue.h @@ -150,6 +150,15 @@ class BoundedSPSCQueueImpl #endif } + /** + * Finish and commit write as a single function + */ + QUILL_ATTRIBUTE_HOT void finish_and_commit_write(integer_type n) noexcept + { + finish_write(n); + commit_write(); + } + QUILL_NODISCARD QUILL_ATTRIBUTE_HOT std::byte* prepare_read() noexcept { if (empty()) diff --git a/include/quill/core/UnboundedSPSCQueue.h b/include/quill/core/UnboundedSPSCQueue.h index 369a860e..aeed47bb 100644 --- a/include/quill/core/UnboundedSPSCQueue.h +++ b/include/quill/core/UnboundedSPSCQueue.h @@ -134,6 +134,15 @@ class UnboundedSPSCQueue */ QUILL_ATTRIBUTE_HOT void commit_write() noexcept { _producer->bounded_queue.commit_write(); } + /** + * Finish and commit write as a single function + */ + QUILL_ATTRIBUTE_HOT void finish_and_commit_write(size_t nbytes) noexcept + { + finish_write(nbytes); + commit_write(); + } + /** * Prepare to read from the buffer * @error_notifier a callback used for notifications to the user