File async_fwd.h

Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2001-2017. ALL RIGHTS RESERVED.

See file LICENSE for terms.

Defines

UCS_ASYNC_PTHREAD_ID_NULL

Typedefs

typedef struct ucs_async_context ucs_async_context_t
typedef void (*ucs_async_event_cb_t)(int id, ucs_event_set_types_t events, void *arg)

Async event callback.

Parameters
  • id – Event id (timer or file descriptor).

  • events – The events that triggered the callback.

  • arg – User-defined argument.

Functions

ucs_status_t ucs_async_set_event_handler(ucs_async_mode_t mode, int event_fd, ucs_event_set_types_t events, ucs_async_event_cb_t cb, void *arg, ucs_async_context_t *async)

Register a file descriptor for monitoring (call handler upon events). Every fd can have only one handler.

Parameters
  • mode – Thread or signal.

  • event_fd – File descriptor to set handler for.

  • events – Events to wait on (UCS_EVENT_SET_EVxxx bits).

  • cb – Callback function to execute.

  • arg – Argument to callback.

  • async – Async context to which events are delivered. If NULL, safety is up to the user.

Returns

Error code as defined by ucs_status_t.

ucs_status_t ucs_async_add_timer(ucs_async_mode_t mode, ucs_time_t interval, ucs_async_event_cb_t cb, void *arg, ucs_async_context_t *async, int *timer_id_p)

Add timer handler.

Parameters
  • mode – Thread or signal.

  • interval – Timer interval.

  • cb – Callback function to execute.

  • arg – Argument to callback.

  • async – Async context to which events are delivered. If NULL, safety is up to the user.

  • timer_id_p – Filled with timer id.

Returns

Error code as defined by ucs_status_t.

ucs_status_t ucs_async_remove_handler(int id, int sync)

Remove an event handler (Timer or event file).

Parameters
  • id – Timer/FD to remove.

  • sync – If nonzero, wait until the handler for this event is not running anymore. If called from the context of the callback, the handler will be removed immediately after the current callback returns.

Returns

Error code as defined by ucs_status_t.

ucs_status_t ucs_async_modify_handler(int fd, ucs_event_set_types_t events)

Modify events mask for an existing event handler (event file).

Parameters
  • fd – File descriptor modify events for.

  • events – New set of events to wait on (UCS_EVENT_SET_EVxxx bits).

Returns

Error code as defined by ucs_status_t.

ucs_status_t ucs_async_context_create(ucs_async_mode_t mode, ucs_async_context_t **async_p)

Create an asynchronous execution context.

Allocate and initialize an asynchronous execution context. This can be used to ensure safe event delivery.

Parameters
  • mode – Indicates whether to use signals or polling threads for waiting.

  • async_p – Event context pointer to initialize.

Returns

Error code as defined by ucs_status_t.

void ucs_async_context_destroy(ucs_async_context_t *async)

Destroy the asynchronous execution context.

Clean up the async context, and release system resources if possible. The context memory released.

Parameters

async – Asynchronous context to clean up.

void ucs_async_poll(ucs_async_context_t *async)

Poll on async context.

Parameters

async – Async context to poll on. NULL polls on all.

void __ucs_async_poll_missed(ucs_async_context_t *async)