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

Function timeout_getretry

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

-------------------------------------------------------------------------*\ * Determines how much time we have left for the next system call, * if the previous call was a failure * 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

91* the number of ms left or -1 if there is no time limit
92\*-------------------------------------------------------------------------*/
93double timeout_getretry(p_timeout tm) {
94 if (tm->block < 0.0 && tm->total < 0.0) {
95 return -1;
96 } else if (tm->block < 0.0) {
97 double t = tm->total - timeout_gettime() + tm->start;
98 return MAX(t, 0.0);
99 } else if (tm->total < 0.0) {
100 double t = tm->block - timeout_gettime() + tm->start;
101 return MAX(t, 0.0);
102 } else {
103 double t = tm->total - timeout_gettime() + tm->start;
104 return MIN(tm->block, MAX(t, 0.0));
105 }
106}
107
108/*-------------------------------------------------------------------------*\
109* Marks the operation start time in structure

Callers 2

socket_waitfdFunction · 0.85
socket_selectFunction · 0.85

Calls 1

timeout_gettimeFunction · 0.85

Tested by

no test coverage detected