Skip to content

iceoryx_binding_c/wait_set.h🔗

Types🔗

Name
typedef CLASS cpp2c_WaitSet * iox_ws_t
wait set handle

Functions🔗

Name
iox_ws_t iox_ws_init(iox_ws_storage_t * self)
initialize wait set handle
void iox_ws_deinit(iox_ws_t const self)
deinitialize wait set handle
uint64_t iox_ws_timed_wait(iox_ws_t const self, struct timespec timeout, iox_notification_info_t *const notificationInfoArray, const uint64_t notificationInfoArrayCapacity, uint64_t * missedElements)
waits until an event occurred or the timeout was reached
uint64_t iox_ws_wait(iox_ws_t const self, iox_notification_info_t *const notificationInfoArray, const uint64_t notificationInfoArrayCapacity, uint64_t * missedElements)
waits until an event occurred
uint64_t iox_ws_size(iox_ws_t const self)
returns the number of registered events/states
uint64_t iox_ws_capacity(iox_ws_t const self)
returns the maximum amount of events/states which can be registered at the waitset
void iox_ws_mark_for_destruction(iox_ws_t const self)
Non-reversible call. After this call iox_ws_wait() and iox_ws_timed_wait() do not block any longer and never return triggered events/states. This function can be used to manually initialize destruction and to wakeup any thread which is waiting in iox_ws_wait() or iox_ws_timed_wait().
ENUM iox_WaitSetResult iox_ws_attach_subscriber_state(iox_ws_t const self, iox_sub_t const subscriber, const ENUM iox_SubscriberState subscriberState, const uint64_t id, void(*)(iox_sub_t) callback)
attaches a subscriber state to a waitset
ENUM iox_WaitSetResult iox_ws_attach_subscriber_state_with_context_data(iox_ws_t const self, iox_sub_t const subscriber, const ENUM iox_SubscriberState subscriberState, const uint64_t id, void()(iox_sub_t, void ) callback, void *const contextData)
attaches a subscriber state to a waitset. The callback has an additional contextData argument to provide access to user defined data.
ENUM iox_WaitSetResult iox_ws_attach_subscriber_event(iox_ws_t const self, iox_sub_t const subscriber, const ENUM iox_SubscriberEvent subscriberEvent, const uint64_t eventId, void(*)(iox_sub_t) callback)
attaches a subscriber event to a waitset
ENUM iox_WaitSetResult iox_ws_attach_subscriber_event_with_context_data(iox_ws_t const self, iox_sub_t const subscriber, const ENUM iox_SubscriberEvent subscriberEvent, const uint64_t eventId, void()(iox_sub_t, void ) callback, void *const contextData)
attaches a subscriber event to a waitset. The callback has an additional contextData argument to provide access to user defined data.
ENUM iox_WaitSetResult iox_ws_attach_user_trigger_event(iox_ws_t const self, iox_user_trigger_t const userTrigger, const uint64_t eventId, void(*)(iox_user_trigger_t) callback)
attaches a user trigger event to a waitset
ENUM iox_WaitSetResult iox_ws_attach_user_trigger_event_with_context_data(iox_ws_t const self, iox_user_trigger_t const userTrigger, const uint64_t eventId, void()(iox_user_trigger_t, void ) callback, void *const contextData)
attaches a user trigger event to a waitset. The callback has an additional contextData argument to provide access to user defined data.
void iox_ws_detach_subscriber_event(iox_ws_t const self, iox_sub_t const subscriber, const ENUM iox_SubscriberEvent subscriberEvent)
detaches a subscriber event from a waitset
void iox_ws_detach_subscriber_state(iox_ws_t const self, iox_sub_t const subscriber, const ENUM iox_SubscriberState subscriberState)
detaches a subscriber state from a waitset
void iox_ws_detach_user_trigger_event(iox_ws_t const self, iox_user_trigger_t const userTrigger)
detaches a user trigger event from a waitset

Types Documentation🔗

typedef iox_ws_t🔗

typedef CLASS cpp2c_WaitSet* iox_ws_t;

wait set handle

Functions Documentation🔗

function iox_ws_init🔗

iox_ws_t iox_ws_init(
    iox_ws_storage_t * self
)

initialize wait set handle

Parameters:

  • self pointer to preallocated memory of size = sizeof(iox_ws_storage_t)

Return: handle to wait set

function iox_ws_deinit🔗

void iox_ws_deinit(
    iox_ws_t const self
)

deinitialize wait set handle

Parameters:

  • self the handle which should be deinitialized

function iox_ws_timed_wait🔗

uint64_t iox_ws_timed_wait(
    iox_ws_t const self,
    struct timespec timeout,
    iox_notification_info_t *const notificationInfoArray,
    const uint64_t notificationInfoArrayCapacity,
    uint64_t * missedElements
)

waits until an event occurred or the timeout was reached

Parameters:

  • self handle to the wait set
  • timeout duration how long this method should wait
  • notificationInfoArray preallocated memory to an array of iox_notification_info_t in which the notification infos, which are describing the occurred event, can be written to
  • notificationInfoArrayCapacity the capacity of the preallocated notificationInfoArray
  • missedElements if the notificationInfoArray has insufficient size the number of missed elements which could not be written into the array are stored here

Return: number of elements which were written into the notificationInfoArray

function iox_ws_wait🔗

uint64_t iox_ws_wait(
    iox_ws_t const self,
    iox_notification_info_t *const notificationInfoArray,
    const uint64_t notificationInfoArrayCapacity,
    uint64_t * missedElements
)

waits until an event occurred

Parameters:

  • self handle to the wait set
  • notificationInfoArray preallocated memory to an array of iox_notification_info_t in which the notification infos, which are describing the occurred event, can be written to
  • notificationInfoArrayCapacity the capacity of the preallocated notificationInfoArray
  • missedElements if the notificationInfoArray has insufficient size the number of missed elements which could not be written into the array are stored here

Return: number of elements which were written into the notificationInfoArray

function iox_ws_size🔗

uint64_t iox_ws_size(
    iox_ws_t const self
)

returns the number of registered events/states

function iox_ws_capacity🔗

uint64_t iox_ws_capacity(
    iox_ws_t const self
)

returns the maximum amount of events/states which can be registered at the waitset

function iox_ws_mark_for_destruction🔗

void iox_ws_mark_for_destruction(
    iox_ws_t const self
)

Non-reversible call. After this call iox_ws_wait() and iox_ws_timed_wait() do not block any longer and never return triggered events/states. This function can be used to manually initialize destruction and to wakeup any thread which is waiting in iox_ws_wait() or iox_ws_timed_wait().

function iox_ws_attach_subscriber_state🔗

ENUM iox_WaitSetResult iox_ws_attach_subscriber_state(
    iox_ws_t const self,
    iox_sub_t const subscriber,
    const ENUM iox_SubscriberState subscriberState,
    const uint64_t id,
    void(*)(iox_sub_t) callback
)

attaches a subscriber state to a waitset

Parameters:

  • self handle to the waitset
  • subscriber the subscriber of the state which should be attached
  • subscriberState the state which should be attached
  • id an arbitrary id which will be tagged to the state
  • callback a callback which is attached to the state

Return: if the attaching was successfull it returns WaitSetResult_SUCCESS, otherwise an enum which describes the error

function iox_ws_attach_subscriber_state_with_context_data🔗

ENUM iox_WaitSetResult iox_ws_attach_subscriber_state_with_context_data(
    iox_ws_t const self,
    iox_sub_t const subscriber,
    const ENUM iox_SubscriberState subscriberState,
    const uint64_t id,
    void(*)(iox_sub_t, void *) callback,
    void *const contextData
)

attaches a subscriber state to a waitset. The callback has an additional contextData argument to provide access to user defined data.

Parameters:

  • self handle to the waitset
  • subscriber the subscriber of the state which should be attached
  • subscriberState the state which should be attached
  • id an arbitrary id which will be tagged to the state
  • callback a callback which is attached to the state
  • contextData a void pointer which is provided as second argument to the callback

Return: if the attaching was successfull it returns WaitSetResult_SUCCESS, otherwise an enum which describes the error

function iox_ws_attach_subscriber_event🔗

ENUM iox_WaitSetResult iox_ws_attach_subscriber_event(
    iox_ws_t const self,
    iox_sub_t const subscriber,
    const ENUM iox_SubscriberEvent subscriberEvent,
    const uint64_t eventId,
    void(*)(iox_sub_t) callback
)

attaches a subscriber event to a waitset

Parameters:

  • self handle to the waitset
  • subscriber the subscriber of the event which should be attached
  • subscriberEvent the event which should be attached
  • eventId an arbitrary id which will be tagged to the event
  • callback a callback which is attached to the event

Return: if the attaching was successfull it returns WaitSetResult_SUCCESS, otherwise an enum which describes the error

function iox_ws_attach_subscriber_event_with_context_data🔗

ENUM iox_WaitSetResult iox_ws_attach_subscriber_event_with_context_data(
    iox_ws_t const self,
    iox_sub_t const subscriber,
    const ENUM iox_SubscriberEvent subscriberEvent,
    const uint64_t eventId,
    void(*)(iox_sub_t, void *) callback,
    void *const contextData
)

attaches a subscriber event to a waitset. The callback has an additional contextData argument to provide access to user defined data.

Parameters:

  • self handle to the waitset
  • subscriber the subscriber of the event which should be attached
  • subscriberEvent the event which should be attached
  • eventId an arbitrary id which will be tagged to the event
  • callback a callback which is attached to the event
  • contextData a void pointer which is provided as second argument to the callback

Return: if the attaching was successfull it returns WaitSetResult_SUCCESS, otherwise an enum which describes the error

function iox_ws_attach_user_trigger_event🔗

ENUM iox_WaitSetResult iox_ws_attach_user_trigger_event(
    iox_ws_t const self,
    iox_user_trigger_t const userTrigger,
    const uint64_t eventId,
    void(*)(iox_user_trigger_t) callback
)

attaches a user trigger event to a waitset

Parameters:

  • self handle to the waitset
  • userTrigger the user trigger of the event which should be attached
  • eventId an arbitrary id which will be tagged to the event
  • callback a callback which is attached to the event

Return: if the attaching was successfull it returns WaitSetResult_SUCCESS, otherwise an enum which describes the error

function iox_ws_attach_user_trigger_event_with_context_data🔗

ENUM iox_WaitSetResult iox_ws_attach_user_trigger_event_with_context_data(
    iox_ws_t const self,
    iox_user_trigger_t const userTrigger,
    const uint64_t eventId,
    void(*)(iox_user_trigger_t, void *) callback,
    void *const contextData
)

attaches a user trigger event to a waitset. The callback has an additional contextData argument to provide access to user defined data.

Parameters:

  • self handle to the waitset
  • userTrigger the user trigger of the event which should be attached
  • eventId an arbitrary id which will be tagged to the event
  • callback a callback which is attached to the event
  • contextData a void pointer which is provided as second argument to the callback

Return: if the attaching was successfull it returns WaitSetResult_SUCCESS, otherwise an enum which describes the error

function iox_ws_detach_subscriber_event🔗

void iox_ws_detach_subscriber_event(
    iox_ws_t const self,
    iox_sub_t const subscriber,
    const ENUM iox_SubscriberEvent subscriberEvent
)

detaches a subscriber event from a waitset

Parameters:

  • self handle to the waitset
  • subscriber the subscriber from which the event should be detached
  • subscriberEvent the event which should be detached from the subscriber

function iox_ws_detach_subscriber_state🔗

void iox_ws_detach_subscriber_state(
    iox_ws_t const self,
    iox_sub_t const subscriber,
    const ENUM iox_SubscriberState subscriberState
)

detaches a subscriber state from a waitset

Parameters:

  • self handle to the waitset
  • subscriber the subscriber from which the state should be detached
  • subscriberState the state which should be detached from the subscriber

function iox_ws_detach_user_trigger_event🔗

void iox_ws_detach_user_trigger_event(
    iox_ws_t const self,
    iox_user_trigger_t const userTrigger
)

detaches a user trigger event from a waitset

Parameters:

  • self handle to the waitset
  • usertrigger the user trigger which should be detached

Source code🔗

// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2020 - 2021 Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

#ifndef IOX_BINDING_C_WAIT_SET_H
#define IOX_BINDING_C_WAIT_SET_H

#include "iceoryx_binding_c/enums.h"
#include "iceoryx_binding_c/internal/c2cpp_binding.h"
#include "iceoryx_binding_c/notification_info.h"
#include "iceoryx_binding_c/subscriber.h"
#include "iceoryx_binding_c/types.h"
#include "iceoryx_binding_c/user_trigger.h"

#include <time.h>

typedef CLASS cpp2c_WaitSet* iox_ws_t;

iox_ws_t iox_ws_init(iox_ws_storage_t* self);

void iox_ws_deinit(iox_ws_t const self);

uint64_t iox_ws_timed_wait(iox_ws_t const self,
                           struct timespec timeout,
                           iox_notification_info_t* const notificationInfoArray,
                           const uint64_t notificationInfoArrayCapacity,
                           uint64_t* missedElements);

uint64_t iox_ws_wait(iox_ws_t const self,
                     iox_notification_info_t* const notificationInfoArray,
                     const uint64_t notificationInfoArrayCapacity,
                     uint64_t* missedElements);

uint64_t iox_ws_size(iox_ws_t const self);

uint64_t iox_ws_capacity(iox_ws_t const self);

void iox_ws_mark_for_destruction(iox_ws_t const self);

ENUM iox_WaitSetResult iox_ws_attach_subscriber_state(iox_ws_t const self,
                                                      iox_sub_t const subscriber,
                                                      const ENUM iox_SubscriberState subscriberState,
                                                      const uint64_t id,
                                                      void (*callback)(iox_sub_t));

ENUM iox_WaitSetResult iox_ws_attach_subscriber_state_with_context_data(iox_ws_t const self,
                                                                        iox_sub_t const subscriber,
                                                                        const ENUM iox_SubscriberState subscriberState,
                                                                        const uint64_t id,
                                                                        void (*callback)(iox_sub_t, void*),
                                                                        void* const contextData);

ENUM iox_WaitSetResult iox_ws_attach_subscriber_event(iox_ws_t const self,
                                                      iox_sub_t const subscriber,
                                                      const ENUM iox_SubscriberEvent subscriberEvent,
                                                      const uint64_t eventId,
                                                      void (*callback)(iox_sub_t));

ENUM iox_WaitSetResult iox_ws_attach_subscriber_event_with_context_data(iox_ws_t const self,
                                                                        iox_sub_t const subscriber,
                                                                        const ENUM iox_SubscriberEvent subscriberEvent,
                                                                        const uint64_t eventId,
                                                                        void (*callback)(iox_sub_t, void*),
                                                                        void* const contextData);

ENUM iox_WaitSetResult iox_ws_attach_user_trigger_event(iox_ws_t const self,
                                                        iox_user_trigger_t const userTrigger,
                                                        const uint64_t eventId,
                                                        void (*callback)(iox_user_trigger_t));

ENUM iox_WaitSetResult iox_ws_attach_user_trigger_event_with_context_data(iox_ws_t const self,
                                                                          iox_user_trigger_t const userTrigger,
                                                                          const uint64_t eventId,
                                                                          void (*callback)(iox_user_trigger_t, void*),
                                                                          void* const contextData);

void iox_ws_detach_subscriber_event(iox_ws_t const self,
                                    iox_sub_t const subscriber,
                                    const ENUM iox_SubscriberEvent subscriberEvent);

void iox_ws_detach_subscriber_state(iox_ws_t const self,
                                    iox_sub_t const subscriber,
                                    const ENUM iox_SubscriberState subscriberState);

void iox_ws_detach_user_trigger_event(iox_ws_t const self, iox_user_trigger_t const userTrigger);

#endif

Updated on 31 May 2022 at 15:29:16 CEST