Function rcl_guard_condition_init

Function Documentation

rcl_ret_t rcl_guard_condition_init(rcl_guard_condition_t *guard_condition, rcl_context_t *context, const rcl_guard_condition_options_t options)

Initialize a rcl guard_condition.

After calling this function on a rcl_guard_condition_t, it can be passed to rcl_wait() and then concurrently it can be triggered to wake-up rcl_wait().

Expected usage:

#include <rcl/rcl.h>

// ... error handling
rcl_guard_condition_t guard_condition = rcl_get_zero_initialized_guard_condition();
// ... customize guard condition options
rcl_ret_t ret = rcl_guard_condition_init(
  &guard_condition, context, rcl_guard_condition_get_default_options());
// ... error handling, and on shutdown do deinitialization:
ret = rcl_guard_condition_fini(&guard_condition);
// ... error handling for rcl_guard_condition_fini()

Attribute

Adherence

Allocates Memory

Yes

Thread-Safe

No

Uses Atomics

No

Lock-Free

Yes

Parameters:
  • guard_condition[inout] preallocated guard_condition structure

  • context[in] the context instance with which the guard condition should be associated

  • options[in] the guard_condition’s options

Returns:

RCL_RET_OK if guard_condition was initialized successfully, or

Returns:

RCL_RET_ALREADY_INIT if the guard condition is already initialized, or

Returns:

RCL_RET_NOT_INIT if the given context is invalid, or

Returns:

RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or

Returns:

RCL_RET_BAD_ALLOC if allocating memory failed, or

Returns:

RCL_RET_ERROR if an unspecified error occurs.