MCPcopy Create free account
hub / github.com/defold/defold / timeout_getretry

Function timeout_getretry

engine/script/src/luasocket/timeout.c:94–107  ·  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

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