1 | #ifndef TIMEOUT_H |
2 | #define TIMEOUT_H |
3 | /*=========================================================================*\ |
4 | * Timeout management functions |
5 | * LuaSocket toolkit |
6 | \*=========================================================================*/ |
7 | #include "lua.h" |
8 | |
9 | /* timeout control structure */ |
10 | typedef struct t_timeout_ { |
11 | double block; /* maximum time for blocking calls */ |
12 | double total; /* total number of miliseconds for operation */ |
13 | double start; /* time of start of operation */ |
14 | } t_timeout; |
15 | typedef t_timeout *p_timeout; |
16 | |
17 | int timeout_open(lua_State *L); |
18 | void timeout_init(p_timeout tm, double block, double total); |
19 | double timeout_get(p_timeout tm); |
20 | double timeout_getretry(p_timeout tm); |
21 | p_timeout timeout_markstart(p_timeout tm); |
22 | double timeout_getstart(p_timeout tm); |
23 | double timeout_gettime(void); |
24 | int timeout_meth_settimeout(lua_State *L, p_timeout tm); |
25 | int timeout_meth_gettimeout(lua_State *L, p_timeout tm); |
26 | |
27 | #define timeout_iszero(tm) ((tm)->block == 0.0) |
28 | |
29 | #endif /* TIMEOUT_H */ |
30 | |