Add heap-free mw::com skeleton and proxy examples#692
Open
jorgecasal wants to merge 21 commits into
Open
Conversation
Add four example binaries demonstrating heap-free usage of the score::mw::com API for ASIL-B/FFI components: - event_send_receive/skeleton: zero-copy event send via SHM ring buffer - event_send_receive/proxy: service discovery and subscription - event_field_update/skeleton: event and field update without heap - event_field_update/proxy: polling receive for events and fields Each example uses a two-phase model where all allocating API calls (Create, OfferService, Subscribe, FindService) happen during init, and the operational phase uses only shared-memory-backed operations (Allocate, Send, GetNewSamples, Update). A lightweight operator new override in heap_check.h aborts on any heap allocation after forbid_heap() is called, verifying the constraint at runtime.
Rename examples:: namespace to sensor:: across all heap-free example sources and update include guard to follow path-based convention. Add tags = ["lint"] to validate_json_schema_test targets.
Remove redundant comments that restate what the code already says. Deduplicate BUILD and .cpp header summaries — .cpp is now canonical. Add "Run alongside the skeleton" note to proxy file headers.
Replace SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD_MESSAGE with the idiomatic
if (!result.has_value()) { LogError; return EXIT_FAILURE; } pattern for
Result<T> checks, matching the ipc_bridge example. Operational-phase error
returns call allow_heap() before returning so teardown stays valid. Remove
redundant comments already covered by the README.
Both applications concurrently offer their own service and discover the other via StartFindService without deadlocking. Document as Pair D in the heap-free README.
Add a skeleton to the start_find_service example so it runs in isolation like the other heap-free groups, instead of depending on the event_send_receive skeleton.
…xamples # Conflicts: # module_integration_test/MODULE.bazel.lock
Moves the heap-free mw::com examples from the top-level examples/ tree into score/mw/com/doc/tutorial/chapter_12/, integrating them as a proper tutorial chapter with README.rst and BUILD targets.
b264220 to
c971ffa
Compare
Explain why OfferService() must precede Proxy::Create() and forbid_heap(): Proxy::Create() allocates heap and can only succeed after the provider has offered its service.
Align chapter_12 examples with the sibling tutorial chapters by replacing init-phase has_value() guards with SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD_MESSAGE.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request adds examples that show how to use the
mw::comprovider (skeleton) and consumer (proxy) sides without allocating on the heap during the operational phase.The examples are integrated into the
mw::comtutorial as chapter 12, underscore/mw/com/doc/tutorial/chapter_12/. They are registered in the tutorial build and documentation (score/mw/com/doc/tutorial/BUILDandREADME.rst), so they render as part of the existing tutorial.Structure
Chapter 12 contains four self-contained scenarios. Each scenario has its own sources, config, logging config, and build file so it can be built and run on its own:
application_a/application_b) that both provide and consume.Each scenario splits the two sides into
providerandconsumer(the bidirectional scenario usesapplication_a/application_b). A shared service interface lives incommon/service_interface.h.A small helper in
heap_check/heap_check.hverifies that no heap allocation happens once the operational phase begins. It overridesoperator new/deleteand aborts on any allocation after the init/operational boundary.Known limitation
The async receive handler cannot yet run without the heap, because the provider side allocates when a consumer registers a receive handler. This is a known framework limit (see the TODO in
scoped_event_receive_handler.h). The examples use polling instead.