-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.h
49 lines (41 loc) · 1.17 KB
/
server.h
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
#ifndef MEMLINK_SERVER_H
#define MEMLINK_SERVER_H
#include <stdio.h>
#include <pthread.h>
#include "queue.h"
#include "info.h"
#define MEMLINK_MAX_THREADS 16
typedef struct _thread_server
{
pthread_t threadid;
struct event_base *base;
struct event notify_event;
int notify_recv_fd;
int notify_send_fd;
Queue *cq;
int running;
int complete;
unsigned short conns;
RwConnInfo *rw_conn_info;
#ifdef DEBUG
int null_dispatch;
#endif
}ThreadServer;
typedef struct _main_server
{
int sock;
struct event_base *base;
struct event event;
ThreadServer threads[MEMLINK_MAX_THREADS];
int lastth; // last thread for dispath
int conn_read;
#ifdef DEBUG
struct event null_dispatch_event;
#endif
}MainServer;
MainServer* mainserver_create();
void mainserver_destroy(MainServer *ms);
void mainserver_loop(MainServer *ms);
void mainserver_read(int fd, short event, void *arg);
int thserver_init(ThreadServer *ts);
#endif