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 */
10typedef 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;
15typedef t_timeout *p_timeout;
16
17int timeout_open(lua_State *L);
18void timeout_init(p_timeout tm, double block, double total);
19double timeout_get(p_timeout tm);
20double timeout_getretry(p_timeout tm);
21p_timeout timeout_markstart(p_timeout tm);
22double timeout_getstart(p_timeout tm);
23double timeout_gettime(void);
24int timeout_meth_settimeout(lua_State *L, p_timeout tm);
25int 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