#ifndef _SIGEV_THREAD_H
#define _SIGEV_THREAD_H
#ifdef __cplusplus
extern "C" {
#endif
#include <signal.h>
#include <port.h>
#include <mqueue.h>
#include <time.h>
#include <limits.h>
#include <semaphore.h>
#include <thread_pool.h>
#define SIGEV_THREAD_TERM 1
typedef enum {TIMER = 1, MQ, AIO} subsystem_t;
typedef struct {
void (*std_func)(union sigval);
union sigval std_arg;
} sigev_thread_data_t;
typedef struct thread_communication_data {
struct thread_communication_data *tcd_next;
struct sigevent tcd_notif;
pthread_attr_t tcd_user_attr;
pthread_attr_t *tcd_attrp;
int tcd_port;
thread_t tcd_server_id;
subsystem_t tcd_subsystem;
tpool_t *tcd_poolp;
mutex_t tcd_lock;
cond_t tcd_cv;
union {
struct {
int overruns;
} timer;
struct {
int msg_enabled;
int msg_closing;
sem_t *msg_avail;
void *msg_object;
void *msg_userval;
} mqueue;
} tcd_object;
} thread_communication_data_t;
#define tcd_overruns tcd_object.timer.overruns
#define tcd_msg_enabled tcd_object.mqueue.msg_enabled
#define tcd_msg_closing tcd_object.mqueue.msg_closing
#define tcd_msg_avail tcd_object.mqueue.msg_avail
#define tcd_msg_object tcd_object.mqueue.msg_object
#define tcd_msg_userval tcd_object.mqueue.msg_userval
extern thread_communication_data_t *setup_sigev_handler(
const struct sigevent *, subsystem_t);
extern void free_sigev_handler(thread_communication_data_t *);
extern int launch_spawner(thread_communication_data_t *);
extern void tcd_teardown(thread_communication_data_t *);
extern void *timer_spawner(void *);
extern int del_sigev_timer(timer_t);
extern int sigev_timer_getoverrun(timer_t);
extern void *mqueue_spawner(void *);
extern void del_sigev_mq(thread_communication_data_t *);
extern void *aio_spawner(void *);
extern int pthread_attr_clone(pthread_attr_t *, const pthread_attr_t *);
extern int pthread_attr_equal(const pthread_attr_t *, const pthread_attr_t *);
extern int _port_dispatch(int, int, int, int, uintptr_t, void *);
extern thread_communication_data_t *sigev_aio_tcd;
extern int timer_max;
extern thread_communication_data_t **timer_tcd;
#ifdef __cplusplus
}
#endif
#endif