James Kuszmaul | b3fb78a | 2024-05-09 15:35:29 -0700 | [diff] [blame] | 1 | #include "aos/ipc_lib/memory_estimation.h" |
| 2 | |
| 3 | #include "aos/ipc_lib/memory_mapped_queue.h" |
| 4 | namespace aos::ipc_lib { |
| 5 | size_t TotalSharedMemoryUsage(const aos::Configuration *config, |
| 6 | const aos::Node *node) { |
| 7 | size_t total_size = 0; |
Austin Schuh | 6bdcc37 | 2024-06-27 14:49:11 -0700 | [diff] [blame] | 8 | const flatbuffers::Vector<flatbuffers::Offset<aos::Channel>> *channels = |
| 9 | config->channels(); |
| 10 | CHECK(channels != nullptr); |
| 11 | for (const aos::Channel *channel : *channels) { |
James Kuszmaul | b3fb78a | 2024-05-09 15:35:29 -0700 | [diff] [blame] | 12 | if (aos::configuration::ChannelIsReadableOnNode(channel, node)) { |
| 13 | total_size += |
| 14 | LocklessQueueMemorySize(MakeQueueConfiguration(config, channel)); |
| 15 | } |
| 16 | } |
| 17 | return total_size; |
| 18 | } |
| 19 | } // namespace aos::ipc_lib |