1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#ifndef __MQ_NTF_H
#define __MQ_NTF_H
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <mqueue.h>
#include "mq_cmd.h"
#include "debug.h"
//async io multiplexer
typedef struct mq_ntf_io_mplx
{
struct timeval tv;
fd_set io_fds;
} mq_ntf_io_mplx;
#define MQ_OUT 1
#define MQ_IN 2
/*
supposed format agni-[id]-[in/out]
in is for input of thread (send to in and thread will recieve),
out if for output of thread (read from out to recieve from thread)
*/
#define MQ_PREFIX "/agni-"
typedef struct mq_ntf_mdt
{
int id;
mqd_t mq_in;
mqd_t mq_out;
//mq_ntf_io_mplx io_mplx;
//_Atomic int used; nado?
} mq_ntf_mdt;
mq_ntf_mdt *mq_ntf_create(int id);
int mq_ntf_open(mq_ntf_mdt *mq, int id);
int mq_ntf_select(mq_ntf_mdt *mq, int dir);
int mq_ntf_read(mq_ntf_mdt *mq, int dir, char *buf, size_t size);
int mq_ntf_write(mq_ntf_mdt *mq, int dir, const char *buf, size_t size);
int mq_ntf_count(mq_ntf_mdt *mq, int dir);
int mq_ntf_close(mq_ntf_mdt *mq);
int mq_ntf_cmd_send(mq_ntf_mdt *mq, mq_cmd *cmd);
int mq_ntf_cmd_recv(mq_ntf_mdt *mq, mq_cmd *cmd);
int mq_drain_q(mqd_t mqd);
int mq_ntf_drain(mq_ntf_mdt *mq);
int mq_ntf_getattr(mq_ntf_mdt *mq, int dir, struct mq_attr **attr);
void mq_ntf_free(mq_ntf_mdt *mq);
#endif
|