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

Function timeout_get

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

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