Skip to content

Commit

Permalink
Improve asyncappender's handling of extremely rare contention (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
swebb2066 authored Nov 8, 2024
1 parent a568d0f commit 3aa883c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/cpp/asyncappender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ void AsyncAppender::append(const spi::LoggingEventPtr& event, Pool& p)
auto index = oldEventCount % priv->buffer.size();
// Wait for a free slot
while (priv->bufferSize <= oldEventCount - priv->dispatchedCount)
;
std::this_thread::yield(); // Allow the dispatch thread to free a slot
// Write to the ring buffer
priv->buffer[index] = AsyncAppenderPriv::EventData{event, pendingCount};
// Notify the dispatch thread that an event has been added
Expand Down

0 comments on commit 3aa883c

Please sign in to comment.