Skip to content

Commit

Permalink
combine finish_write and commit_write to a single function
Browse files Browse the repository at this point in the history
  • Loading branch information
odygrd committed Sep 22, 2024
1 parent a39d257 commit a03e9c0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 1 addition & 2 deletions include/quill/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<frontend_options_t::queue_type>().finish_write(total_size);
thread_context->get_spsc_queue<frontend_options_t::queue_type>().commit_write();
thread_context->get_spsc_queue<frontend_options_t::queue_type>().finish_and_commit_write(total_size);

if constexpr (immediate_flush)
{
Expand Down
9 changes: 9 additions & 0 deletions include/quill/core/BoundedSPSCQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
9 changes: 9 additions & 0 deletions include/quill/core/UnboundedSPSCQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a03e9c0

Please sign in to comment.