forked from lilydjwg/udt_py
-
Notifications
You must be signed in to change notification settings - Fork 2
/
udt_py.h
75 lines (60 loc) · 1.21 KB
/
udt_py.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <Python.h>
#include <udt.h>
#include <map>
typedef struct py_udt_error : std::exception {} py_udt_error;
typedef struct cc_general_error : std::exception {} cc_general_error;
/*
FIXME - Need to implement GIL handling
*/
class AutoGILCallOut
{
public:
AutoGILCallOut();
~AutoGILCallOut();
private:
PyThreadState *state;
};
class AutoGILCallBack
{
public:
AutoGILCallBack();
~AutoGILCallBack();
private:
PyGILState_STATE state;
};
class AutoDecref
{
public:
AutoDecref(PyObject *o);
~AutoDecref();
void ok();
private:
PyObject *ptr;
};
typedef struct
{
PyObject_HEAD;
UDTSOCKET cc_socket;
int family;
int type;
int proto;
} pyudt_socket_object;
typedef struct
{
PyObject_HEAD;
int eid;
} pyudt_epoll_object;
class RecvBuffer
{
public:
RecvBuffer(unsigned int size);
~RecvBuffer();
char *get_head();
unsigned int get_max_len();
unsigned int get_buf_len();
unsigned int set_buf_len(unsigned int len);
private:
char *head;
unsigned int max_buf_len;
unsigned int buf_len;
};