Commit e2d5a3f6 authored by Phil Willoughby's avatar Phil Willoughby Committed by Facebook GitHub Bot

expose LockFreeRingBuffer internal address/size

Summary: This is useful if your environment takes partial dumps of the process on crash - you can tell the process which does that to include the memory range of the flight recorder in what is dumped.

Differential Revision: D27206631

fbshipit-source-id: b3679004930486094e6030b5b39ee02d01bc7617
parent 02e534fb
......@@ -21,6 +21,7 @@
#include <cstring>
#include <memory>
#include <type_traits>
#include <utility>
#include <folly/Portability.h>
#include <folly/Traits.h>
......@@ -158,6 +159,20 @@ class LockFreeRingBuffer {
return Cursor(ticket - backStep);
}
// Returns the address and length of the internal buffer.
// This can be useful to know if you are using LockFreeRingBuffer to store
// things you want to be able to retrieve after a crash, and you are not
// dumping all memory when a crash occurs: you can add the result of this
// call to the list of memory regions that are dumped.
// See `folly::FlightRecorder` for this use-case.
// It's not useful, or safe, to inspect this region at runtime (other than
// through the APIs above)
std::pair<void const*, size_t> internalBufferLocation() const {
return std::make_pair(
static_cast<void const*>(slots_.get()),
sizeof(detail::RingBufferSlot<T, Atom>[capacity_]));
}
~LockFreeRingBuffer() {}
private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment