In include/behaviortree_cpp/utils/signal.h:
-
Doc comment typo: "Signal/Slop implementation" should be "Signal/Slot implementation" (line 11).
-
Signal::subscribe() returns a Subscriber (a shared_ptr that is the only strong
reference keeping the subscription alive; subscribers_ only holds a weak_ptr).
If the caller discards the return value, the shared_ptr refcount drops to zero
immediately, the weak_ptr expires, and the subscription is silently dropped before
it can ever fire. Marking it [[nodiscard]] would catch this footgun at compile time:
[[nodiscard]] Subscriber subscribe(CallableFunction func)
Happy to send a PR for both if useful.
In
include/behaviortree_cpp/utils/signal.h:Doc comment typo: "Signal/Slop implementation" should be "Signal/Slot implementation" (line 11).
Signal::subscribe()returns aSubscriber(ashared_ptrthat is the only strongreference keeping the subscription alive;
subscribers_only holds aweak_ptr).If the caller discards the return value, the shared_ptr refcount drops to zero
immediately, the weak_ptr expires, and the subscription is silently dropped before
it can ever fire. Marking it
[[nodiscard]]would catch this footgun at compile time:[[nodiscard]] Subscriber subscribe(CallableFunction func)
Happy to send a PR for both if useful.