Expose the private buffers from fetchers too
This is handy for the same use cases where getting the shared memory is:
teaching other libraries about it to optimize its usage.
Change-Id: I41657333a70c2b9c9dbf8a30f0c52251eb590ba4
diff --git a/aos/events/shm_event_loop.h b/aos/events/shm_event_loop.h
index f832242..55fc85f 100644
--- a/aos/events/shm_event_loop.h
+++ b/aos/events/shm_event_loop.h
@@ -81,12 +81,19 @@
// this.
absl::Span<char> GetWatcherSharedMemory(const Channel *channel);
- // Returns the local mapping of the shared memory used by the provided Sender
+ // Returns the local mapping of the shared memory used by the provided Sender.
template <typename T>
absl::Span<char> GetSenderSharedMemory(aos::Sender<T> *sender) const {
return GetShmSenderSharedMemory(GetRawSender(sender));
}
+ // Returns the local mapping of the private memory used by the provided
+ // Fetcher to hold messages.
+ template <typename T>
+ absl::Span<char> GetFetcherPrivateMemory(aos::Fetcher<T> *fetcher) const {
+ return GetShmFetcherPrivateMemory(GetRawFetcher(fetcher));
+ }
+
private:
friend class shm_event_loop_internal::ShmWatcherState;
friend class shm_event_loop_internal::ShmTimerHandler;
@@ -107,9 +114,13 @@
// Returns the TID of the event loop.
pid_t GetTid() override;
- // Private method to access the shared memory mapping of a ShmSender
+ // Private method to access the shared memory mapping of a ShmSender.
absl::Span<char> GetShmSenderSharedMemory(const aos::RawSender *sender) const;
+ // Private method to access the private memory mapping of a ShmFetcher.
+ absl::Span<char> GetShmFetcherPrivateMemory(
+ const aos::RawFetcher *fetcher) const;
+
std::vector<std::function<void()>> on_run_;
int priority_ = 0;
cpu_set_t affinity_ = DefaultAffinity();