timeout.h 975 B

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