Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor AnySubscriptionCallback and add/deprecate callback signatures #1598

Merged
merged 18 commits into from
Apr 3, 2021

Commits on Apr 1, 2021

  1. refactor AnySubscriptionCallback to...

    use std::variant and make the dispatch functions constexpr,
    avoiding runtime dispatching.
    
    Also, deprecate the std::function<void (std::shared_ptr<MessageT>)> signature,
    as it is unsafe to share one shared_ptr when multiple subscriptions take it,
    because they could mutate MessageT while others are using it. So you'd have to
    make a copy for each subscription, which is no different than the
    std::unique_ptr<MessageT> signature or the user making their own copy in a
    shared_ptr from the const MessageT & signature or the
    std::shared_ptr<const MessageT> signature.
    
    Added a std::function<void (const std::shared_ptr<const MessageT> &)> signature
    to go along side the existing
    std::function<void (std::shared_ptr<const MessageT>)> signature.
    
    Removed redundant 'const' before pass-by-value signatures, e.g.
    std::function<void (const shared_ptr<const MessageT>)> became
    std::function<void (shared_ptr<const MessageT>)>.
    This will not affect API or any users using the old style.
    
    Signed-off-by: William Woodall <william@osrfoundation.org>
    wjwwood committed Apr 1, 2021
    Configuration menu
    Copy the full SHA
    96a04a1 View commit details
    Browse the repository at this point in the history
  2. fix use of std::bind, free functions, etc. using new function_traits:…

    …:as_std_function<>
    
    Signed-off-by: William Woodall <william@osrfoundation.org>
    wjwwood committed Apr 1, 2021
    Configuration menu
    Copy the full SHA
    1418e8e View commit details
    Browse the repository at this point in the history
  3. fix use of const MessageT & callbacks by fixing subscriptin_traits

    Signed-off-by: William Woodall <william@osrfoundation.org>
    wjwwood committed Apr 1, 2021
    Configuration menu
    Copy the full SHA
    76edcd3 View commit details
    Browse the repository at this point in the history
  4. fix deprecation warnings

    Signed-off-by: William Woodall <william@osrfoundation.org>
    wjwwood committed Apr 1, 2021
    Configuration menu
    Copy the full SHA
    2bec5c4 View commit details
    Browse the repository at this point in the history
  5. use target_compile_features to require c++17 for downstream users of …

    …rclcpp
    
    Signed-off-by: William Woodall <william@osrfoundation.org>
    wjwwood committed Apr 1, 2021
    Configuration menu
    Copy the full SHA
    fda4a9f View commit details
    Browse the repository at this point in the history
  6. uncrustify

    Signed-off-by: William Woodall <william@osrfoundation.org>
    wjwwood committed Apr 1, 2021
    Configuration menu
    Copy the full SHA
    3d4518d View commit details
    Browse the repository at this point in the history
  7. cpplint

    Signed-off-by: William Woodall <william@osrfoundation.org>
    wjwwood committed Apr 1, 2021
    Configuration menu
    Copy the full SHA
    02e1eef View commit details
    Browse the repository at this point in the history
  8. use target_compile_features(... cxx_std_17)

    Signed-off-by: William Woodall <william@osrfoundation.org>
    wjwwood committed Apr 1, 2021
    Configuration menu
    Copy the full SHA
    fdc6920 View commit details
    Browse the repository at this point in the history
  9. Keep both std::shared_ptr<const MessageT> and const std::shared_ptr<c…

    …onst MessageT> & signatures.
    
    The const std::shared_ptr<const MessageT> & signature is being kept because it
    can be more flexible and efficient than std::shared_ptr<const MessageT>, but
    costs realtively little to support.
    
    The std::shared_ptr<const MessageT> signature is being kept because we want to
    avoid deprecating it and causing disruption, and because it is convenient to
    write, and in most cases will not materially impact the performance.
    
    Signed-off-by: William Woodall <william@osrfoundation.org>
    wjwwood committed Apr 1, 2021
    Configuration menu
    Copy the full SHA
    d7840fd View commit details
    Browse the repository at this point in the history
  10. defer deprecation of the shared_ptr<MessageT> sub callbacks

    Signed-off-by: William Woodall <william@osrfoundation.org>
    wjwwood committed Apr 1, 2021
    Configuration menu
    Copy the full SHA
    0811b7f View commit details
    Browse the repository at this point in the history
  11. fix unused variable warning

    Signed-off-by: William Woodall <william@osrfoundation.org>
    wjwwood committed Apr 1, 2021
    Configuration menu
    Copy the full SHA
    2cea8ca View commit details
    Browse the repository at this point in the history
  12. small fixups to AnySubscriptionCallback

    Signed-off-by: William Woodall <william@osrfoundation.org>
    wjwwood committed Apr 1, 2021
    Configuration menu
    Copy the full SHA
    934d8be View commit details
    Browse the repository at this point in the history
  13. add check for unset AnySubscriptionCallback in dispatch methods

    Signed-off-by: William Woodall <william@osrfoundation.org>
    wjwwood committed Apr 1, 2021
    Configuration menu
    Copy the full SHA
    84c7372 View commit details
    Browse the repository at this point in the history
  14. update dispatch methods to handle all scenarios

    Signed-off-by: William Woodall <william@osrfoundation.org>
    wjwwood committed Apr 1, 2021
    Configuration menu
    Copy the full SHA
    0903161 View commit details
    Browse the repository at this point in the history
  15. updated tests for AnySubscriptionCallback, include full parameterized…

    … i/o matrix
    
    Signed-off-by: William Woodall <william@osrfoundation.org>
    wjwwood committed Apr 1, 2021
    Configuration menu
    Copy the full SHA
    f923c2b View commit details
    Browse the repository at this point in the history
  16. fixup test with changed assumption

    Signed-off-by: William Woodall <william@osrfoundation.org>
    wjwwood committed Apr 1, 2021
    Configuration menu
    Copy the full SHA
    a5ff680 View commit details
    Browse the repository at this point in the history

Commits on Apr 2, 2021

  1. remove use of std::unary_function, which was removed in c++17

    Signed-off-by: William Woodall <william@osrfoundation.org>
    wjwwood committed Apr 2, 2021
    Configuration menu
    Copy the full SHA
    2590fd0 View commit details
    Browse the repository at this point in the history
  2. silence c++17 warnings on windows for now

    Signed-off-by: William Woodall <william@osrfoundation.org>
    wjwwood committed Apr 2, 2021
    Configuration menu
    Copy the full SHA
    ac4b35c View commit details
    Browse the repository at this point in the history