2005-10-06 21:40:59 -07:00
|
|
|
#ifndef TIMEOUT_H
|
|
|
|
#define TIMEOUT_H
|
2003-03-28 13:08:50 -08:00
|
|
|
/*=========================================================================*\
|
|
|
|
* Timeout management functions
|
2003-06-26 11:47:49 -07:00
|
|
|
* LuaSocket toolkit
|
2003-03-28 13:08:50 -08:00
|
|
|
\*=========================================================================*/
|
2019-02-27 20:01:16 -08:00
|
|
|
#include "luasocket.h"
|
2003-05-24 18:54:13 -07:00
|
|
|
|
|
|
|
/* timeout control structure */
|
2005-10-06 21:40:59 -07:00
|
|
|
typedef struct t_timeout_ {
|
2004-06-30 20:32:09 -07:00
|
|
|
double block; /* maximum time for blocking calls */
|
2005-03-10 18:21:27 -08:00
|
|
|
double total; /* total number of miliseconds for operation */
|
2004-06-30 20:32:09 -07:00
|
|
|
double start; /* time of start of operation */
|
2005-10-06 21:40:59 -07:00
|
|
|
} t_timeout;
|
|
|
|
typedef t_timeout *p_timeout;
|
2002-07-03 12:06:54 -07:00
|
|
|
|
2019-02-28 15:32:07 -08:00
|
|
|
#ifndef _WIN32
|
2019-02-27 20:01:16 -08:00
|
|
|
#pragma GCC visibility push(hidden)
|
2019-02-28 15:32:07 -08:00
|
|
|
#endif
|
2019-02-27 20:01:16 -08:00
|
|
|
|
2005-10-06 21:40:59 -07:00
|
|
|
void timeout_init(p_timeout tm, double block, double total);
|
|
|
|
double timeout_get(p_timeout tm);
|
2019-02-27 20:01:16 -08:00
|
|
|
double timeout_getstart(p_timeout tm);
|
2005-10-06 21:40:59 -07:00
|
|
|
double timeout_getretry(p_timeout tm);
|
|
|
|
p_timeout timeout_markstart(p_timeout tm);
|
2019-02-27 20:01:16 -08:00
|
|
|
|
2005-10-06 21:40:59 -07:00
|
|
|
double timeout_gettime(void);
|
2019-02-27 20:01:16 -08:00
|
|
|
|
|
|
|
int timeout_open(lua_State *L);
|
|
|
|
|
2005-10-06 21:40:59 -07:00
|
|
|
int timeout_meth_settimeout(lua_State *L, p_timeout tm);
|
2016-03-04 10:36:32 -08:00
|
|
|
int timeout_meth_gettimeout(lua_State *L, p_timeout tm);
|
2002-07-03 12:06:54 -07:00
|
|
|
|
2019-02-28 15:32:07 -08:00
|
|
|
#ifndef _WIN32
|
2019-02-27 20:01:16 -08:00
|
|
|
#pragma GCC visibility pop
|
2019-02-28 15:32:07 -08:00
|
|
|
#endif
|
2019-02-27 20:01:16 -08:00
|
|
|
|
2005-10-06 21:40:59 -07:00
|
|
|
#define timeout_iszero(tm) ((tm)->block == 0.0)
|
2004-07-14 23:11:53 -07:00
|
|
|
|
2005-10-06 21:40:59 -07:00
|
|
|
#endif /* TIMEOUT_H */
|