#ifndef UCS_ASYNC_INT_H
#define UCS_ASYNC_INT_H
#include "async.h"
#include <ucs/datastruct/queue.h>
#include <ucs/time/timerq.h>
typedef struct ucs_async_handler ucs_async_handler_t;
struct ucs_async_handler {
int id;
ucs_async_mode_t mode;
ucs_event_set_types_t events;
pthread_t caller;
ucs_async_event_cb_t cb;
void *arg;
ucs_async_context_t *async;
volatile uint32_t missed;
volatile uint32_t refcount;
};
ucs_status_t ucs_async_dispatch_handlers(int *handler_ids, size_t count,
ucs_event_set_types_t events);
ucs_status_t ucs_async_dispatch_timerq(ucs_timer_queue_t *timerq,
ucs_time_t current_time);
typedef void (*ucs_async_init_t)();
typedef void (*ucs_async_cleanup_t)();
typedef int (*ucs_async_is_from_async_t)();
typedef void (*ucs_async_block_t)();
typedef void (*ucs_async_unblock_t)();
typedef ucs_status_t (*ucs_async_context_init_t)(ucs_async_context_t *async);
typedef void (*ucs_async_context_cleanup_t)(ucs_async_context_t *async);
typedef int (*ucs_async_context_try_block_t)(ucs_async_context_t *async);
typedef void (*ucs_async_context_unblock_t)(ucs_async_context_t *async);
typedef ucs_status_t (*ucs_async_add_event_fd_t)(ucs_async_context_t *async,
int event_fd,
ucs_event_set_types_t events);
typedef ucs_status_t (*ucs_async_remove_event_fd_t)(ucs_async_context_t *async,
int event_fd);
typedef ucs_status_t (*ucs_async_modify_event_fd_t)(ucs_async_context_t *async,
int event_fd,
ucs_event_set_types_t events);
typedef ucs_status_t (*ucs_async_add_timer_t)(ucs_async_context_t *async,
int timer_id,
ucs_time_t interval);
typedef ucs_status_t (*ucs_async_remove_timer_t)(ucs_async_context_t *async,
int timer_id);
typedef struct ucs_async_ops {
ucs_async_init_t init;
ucs_async_cleanup_t cleanup;
ucs_async_is_from_async_t is_from_async;
ucs_async_block_t block;
ucs_async_unblock_t unblock;
ucs_async_context_init_t context_init;
ucs_async_context_cleanup_t context_cleanup;
ucs_async_context_try_block_t context_try_block;
ucs_async_context_unblock_t context_unblock;
ucs_async_add_event_fd_t add_event_fd;
ucs_async_remove_event_fd_t remove_event_fd;
ucs_async_modify_event_fd_t modify_event_fd;
ucs_async_add_timer_t add_timer;
ucs_async_remove_timer_t remove_timer;
} ucs_async_ops_t;
extern ucs_async_ops_t ucs_async_thread_spinlock_ops;
extern ucs_async_ops_t ucs_async_thread_mutex_ops;
extern ucs_async_ops_t ucs_async_signal_ops;
#endif