MCPcopy Create free account
hub / github.com/Tencent/UnLua / timeout_get

Function timeout_get

Plugins/UnLuaExtensions/LuaSocket/Source/src/timeout.cpp:60–72  ·  view source on GitHub ↗

-------------------------------------------------------------------------*\ * Determines how much time we have left for the next system call, * if the previous call was successful * Input * tm: timeout control structure * Returns * the number of ms left or -1 if there is no time limit \*-------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

58* the number of ms left or -1 if there is no time limit
59\*-------------------------------------------------------------------------*/
60double timeout_get(p_timeout tm) {
61 if (tm->block < 0.0 && tm->total < 0.0) {
62 return -1;
63 } else if (tm->block < 0.0) {
64 double t = tm->total - timeout_gettime() + tm->start;
65 return MAX(t, 0.0);
66 } else if (tm->total < 0.0) {
67 return tm->block;
68 } else {
69 double t = tm->total - timeout_gettime() + tm->start;
70 return MIN(tm->block, MAX(t, 0.0));
71 }
72}
73
74/*-------------------------------------------------------------------------*\
75* Returns time since start of operation

Callers 2

socket_waitfdFunction · 0.85
socket_selectFunction · 0.85

Calls 1

timeout_gettimeFunction · 0.85

Tested by

no test coverage detected