-
Notifications
You must be signed in to change notification settings - Fork 163
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
Add rcl guard condition on_trigger_callback #966
Closed
mauropasse
wants to merge
1
commit into
ros2:rolling
from
mauropasse:mauro/add-guard-condition-on-trigger-callback
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ extern "C" | |
|
||
#include "rcl/allocator.h" | ||
#include "rcl/context.h" | ||
#include "rcl/event_callback.h" | ||
#include "rcl/macros.h" | ||
#include "rcl/types.h" | ||
#include "rcl/visibility_control.h" | ||
|
@@ -48,6 +49,14 @@ typedef struct rcl_guard_condition_options_s | |
rcl_allocator_t allocator; | ||
} rcl_guard_condition_options_t; | ||
|
||
/// On trigger callback data | ||
typedef struct rcl_guard_condition_callback_data_s | ||
{ | ||
rcl_event_callback_t on_trigger_callback; | ||
const void * user_data; | ||
size_t trigger_count; | ||
} rcl_guard_condition_callback_data_t; | ||
|
||
/// Return a rcl_guard_condition_t struct with members set to `NULL`. | ||
RCL_PUBLIC | ||
RCL_WARN_UNUSED | ||
|
@@ -262,6 +271,34 @@ RCL_WARN_UNUSED | |
rmw_guard_condition_t * | ||
rcl_guard_condition_get_rmw_handle(const rcl_guard_condition_t * guard_condition); | ||
|
||
/// Set the on trigger callback function for the guard_condition. | ||
/** | ||
* This API sets the callback function to be called whenever the | ||
* guard_condition is triggered. | ||
* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be nice to add explanation about how |
||
* | ||
* <hr> | ||
* Attribute | Adherence | ||
* ------------------ | ------------- | ||
* Allocates Memory | No | ||
* Thread-Safe | No | ||
* Uses Atomics | No | ||
* Lock-Free | No | ||
* | ||
* \param[in] guard_condition The guard_condition on which to set the callback | ||
* \param[in] on_trigger_callback The callback to be called when guard condition is triggered | ||
* \param[in] user_data Given to the callback when called later, may be NULL | ||
* \return `RCL_RET_OK` if successful, or | ||
* \return `RCL_RET_INVALID_ARGUMENT` if `guard_condition` is NULL | ||
*/ | ||
RCL_PUBLIC | ||
RCL_WARN_UNUSED | ||
rcl_ret_t | ||
rcl_guard_condition_set_on_trigger_callback( | ||
const rcl_guard_condition_t * guard_condition, | ||
rcl_event_callback_t on_trigger_callback, | ||
const void * user_data); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mauropasse implementation looks good, but could you explain the use case of
trigger_count
?