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

Lifecycle improvements #47

Open
wants to merge 46 commits into
base: develop
Choose a base branch
from
Open

Commits on Aug 16, 2023

  1. add executor interface

    Executors should allow for more
    flexibility and encapsulation.
    
     create mode 100644 src/ros2cs/ros2cs_core/interfaces/IExecutor.cs
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    13a4d04 View commit details
    Browse the repository at this point in the history
  2. refactor Node and create Context

     - Context is a non-static version of Ros2cs without executor functionality
     - Context and Node are now sealed
     - Node is now internal and is preventing its Context from being collected by the GC
     - not calling Dispose may now leak resources since internal collections may be finalized in the finalizer
     - sizes of rcl_node_t and rcl_conext_t are now invisible to C# code
    
     create mode 100644 src/ros2cs/ros2cs_core/Context.cs
     delete mode 100644 src/ros2cs/ros2cs_core/Ros2cs.cs
     create mode 100644 src/ros2cs/ros2cs_core/interfaces/IContext.cs
     create mode 100644 src/ros2cs/ros2cs_core/utils/MappingValueView.cs
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    8c580c2 View commit details
    Browse the repository at this point in the history
  3. improve description of IExtendedDisposable.IsDisposed

    This should prevent misunderstandings regarding being
    in an disposed state and being disposed successfully.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    3f53085 View commit details
    Browse the repository at this point in the history
  4. refactor Publisher

     - is now sealed and internal
     - rcl_publisher_t size is now invisible to C# code
     - removes himself from node on dispose
     - prevents Node from being collected by the GC
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    51495c2 View commit details
    Browse the repository at this point in the history
  5. add IWaitable

    This interface contains all methods necessary
    for executors to process work.
    The async version is equivalent to the non-async version
    and an optimization opportunity for task based executors.
    
     create mode 100644 src/ros2cs/ros2cs_core/interfaces/IWaitable.cs
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    5ce3a79 View commit details
    Browse the repository at this point in the history
  6. refactor Subscription

     - is now sealed and internal
     - rcl_subscription_t size is now invisible to C# code
     - removes himself from node on dispose
     - prevents Node from being collected by the GC
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    a2c32d5 View commit details
    Browse the repository at this point in the history
  7. refactor Service

     - is now sealed and internal
     - rcl_service_t size is now invisible to C# code
     - removes himself from node on dispose
     - prevents Node from being collected by the GC
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    40f53d9 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    7858e3d View commit details
    Browse the repository at this point in the history
  9. rename MappingValueView -> MappedValueDictionary

     rename src/ros2cs/ros2cs_core/utils/{MappingValueView.cs => MappedValueDictionary.cs} (87%)
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    d314def View commit details
    Browse the repository at this point in the history
  10. add LockedDictionary

     create mode 100644 src/ros2cs/ros2cs_core/utils/LockedDictionary.cs
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    c3fbc80 View commit details
    Browse the repository at this point in the history
  11. fix service default qos

    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    33d3be0 View commit details
    Browse the repository at this point in the history
  12. refactor Client

     - is now sealed and internal
     - rcl_client_t size is now invisible to C# code
     - removes himself from node on dispose
     - prevents Node from being collected by the GC
     - reduced code duplication
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    4a24200 View commit details
    Browse the repository at this point in the history
  13. add debug assertions

    These assertions are only enabled in debug mode
    and should make finding bugs easier.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    dabf904 View commit details
    Browse the repository at this point in the history
  14. add calls to GC.KeepAlive(this)

    This should prevent the GC from starting
    finalization while a native call is running.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    d6b5e72 View commit details
    Browse the repository at this point in the history
  15. add internal Removal methods to Node

    This enforces more encapsulation than direct internal access.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    83a2a2b View commit details
    Browse the repository at this point in the history
  16. refactor IExecutor interface

    Make setting `INode.Executor` the task of the executor
    since `INode.SwapExecutor` is performing two actions at once
    (adding and removing) which can complicate error handling.
    Furthermore, `IExecutor.Wake` is split to allow notifying
    executors that changes occurred without being forced to wait.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    0fd008a View commit details
    Browse the repository at this point in the history
  17. update tests and fix C interop

    Returning false could fail since the size
    of a bool is different between C, C++ and C#.
    This is fixed by adding wrappers which assure that
    a byte is returned containing 1 for true and 0 for false.
    Furthermore this commit adds missing attributes to ref
    parameters in NativeRcl or turns them into out parameters.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    667f68f View commit details
    Browse the repository at this point in the history
  18. update CMakeLists.txt

    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    561ec07 View commit details
    Browse the repository at this point in the history
  19. add IWaitable.Handle

    This allows wrappers to be put in a wait set by delegating to the wrapped implementation.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    3a16827 View commit details
    Browse the repository at this point in the history
  20. refactor WaitSet

     - allow for checking which resources became ready
     - implement IExtendedDisposable and IReadOnlyCollection interfaces
     - abstract away wait set resizing and filling
     - hide struct behind IntPtr and C wrappers to handle layout changes and GC moves
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    11c3696 View commit details
    Browse the repository at this point in the history
  21. add GuardCondition

    It is currently only internal and used for the executor.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    2a42d14 View commit details
    Browse the repository at this point in the history
  22. add ManualExecutor

     - implementation of IExecutor which has to be spun manually
     - roughly the same as the old spin logic in Ros2cs
     - does not rescan every spin
    
     create mode 100644 src/ros2cs/ros2cs_core/executors/ManualExecutor.cs
     create mode 100644 src/ros2cs/ros2cs_tests/src/ManualExecutorTest.cs
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    bc73ca7 View commit details
    Browse the repository at this point in the history
  23. doc and tests updates for guard condition behavior

    Guard conditions seem to stay triggered until waited on.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    c635d56 View commit details
    Browse the repository at this point in the history
  24. remove redundant IsDisposed checks

    The checks are already done by rcl.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    b1594c1 View commit details
    Browse the repository at this point in the history
  25. improve Context documentation on thread safety

    Creating nodes is now thread safe.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    8adf7e5 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    802dc40 View commit details
    Browse the repository at this point in the history
  27. improve Publisher documentation

    The class is now public to allow users to read
    the implementation documentation like thread safety.
    To prevent access to internal methods the class remains sealed
    and uses explicit interface implementations.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    acb813f View commit details
    Browse the repository at this point in the history
  28. improve Subscription documentation

    The class is now public to allow users to read
    the implementation documentation like thread safety.
    To prevent access to internal methods the class remains sealed
    and uses explicit interface implementations.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    2f72a51 View commit details
    Browse the repository at this point in the history
  29. improve Service documentation

    The class is now public to allow users to read
    the implementation documentation like thread safety.
    To prevent access to internal methods the class remains sealed
    and uses explicit interface implementations.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    4535da3 View commit details
    Browse the repository at this point in the history
  30. improve Client documentation

    The class is now public to allow users to read
    the implementation documentation like thread safety.
    To prevent access to internal methods the class remains sealed
    and uses explicit interface implementations.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    1d6cc1d View commit details
    Browse the repository at this point in the history
  31. improve Node documentation

    The class is now public to allow users to read
    the implementation documentation like thread safety.
    Furthermore, the primitive collections (and by extension their methods)
    are now thread safe.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    9bcafbd View commit details
    Browse the repository at this point in the history
  32. remove IWaitable.TryProcessAsync

    Async operations are out of scope for this branch.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    cd161f0 View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    1e51b52 View commit details
    Browse the repository at this point in the history
  34. make Node.Executor thread safe

    This commit prevents node primitives from
    waiting on the wrong executor while being disposed.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    4a4f19b View commit details
    Browse the repository at this point in the history
  35. Configuration menu
    Copy the full SHA
    7556027 View commit details
    Browse the repository at this point in the history
  36. update examples

    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    2fbfeae View commit details
    Browse the repository at this point in the history
  37. simplify WaitSet

    The results are now only exposed as `IEnumerable`s.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    89aaf68 View commit details
    Browse the repository at this point in the history
  38. add ManualExecutor.SpinWhile

    This should be more user friendly than `ManualExecutor.Spin`.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    c89ea26 View commit details
    Browse the repository at this point in the history
  39. Configuration menu
    Copy the full SHA
    f4ce8ae View commit details
    Browse the repository at this point in the history
  40. add copyright notices to new files

    Files created by this PR are under the copyright
    of ADVITEC Informatik GmbH as suggested by review.
    The license is the same as existing files.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    c248106 View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    38e0534 View commit details
    Browse the repository at this point in the history
  42. Configuration menu
    Copy the full SHA
    f062a98 View commit details
    Browse the repository at this point in the history
  43. dispose guard conditions after invoking IContext.OnShutdown

    This prevents violating the documentation.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    52a331d View commit details
    Browse the repository at this point in the history
  44. dispose wait set after invoking IContext.OnShutdown

    This prevents violating the documentation.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    3530611 View commit details
    Browse the repository at this point in the history
  45. Add executor spinning in the background

    To prevent users from having to implement
    the feature themselves and provide an alternative
    to the old spinning behaviour.
    The new executor uses a long running `Task` instead of a `Thread`
    to provide better integration with the C# ecosystem.
    Deric-W committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    2e5bdd9 View commit details
    Browse the repository at this point in the history

Commits on Sep 1, 2023

  1. fix thread starvation in ManualExecutor.*Wait

    Threads may fail to wake for some time since the method waits
    on a `ManualResetEventSlim` which is reset before the next spin.
    To prevent such cases the waiting condition has been modified
    to additionally check an integer which is incremented after every spin
    to detected if the spin which was waited upon has ended.
    Deric-W committed Sep 1, 2023
    Configuration menu
    Copy the full SHA
    77bfffd View commit details
    Browse the repository at this point in the history