MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / addTimeout

Method addTimeout

src/profiler.cpp:1408–1437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1406}
1407
1408u64 Profiler::addTimeout(u64 start_micros, int timeout) {
1409 if (timeout == 0) {
1410 return 0x7fffffffffffffffULL;
1411 } else if (timeout > 0) {
1412 return start_micros + (u64)timeout * 1000000ULL;
1413 }
1414
1415 time_t start_seconds = start_micros / 1000000ULL;
1416 struct tm t;
1417 localtime_r(&start_seconds, &t);
1418
1419 int hh = (timeout >> 16) & 0xff;
1420 if (hh < 24) {
1421 t.tm_hour = hh;
1422 }
1423 int mm = (timeout >> 8) & 0xff;
1424 if (mm < 60) {
1425 t.tm_min = mm;
1426 }
1427 int ss = timeout & 0xff;
1428 if (ss < 60) {
1429 t.tm_sec = ss;
1430 }
1431
1432 time_t result = mktime(&t);
1433 if (result <= start_seconds) {
1434 result += (hh < 24 ? 86400 : (mm < 60 ? 3600 : 60));
1435 }
1436 return (u64)result * 1000000ULL;
1437}
1438
1439void Profiler::startTimer() {
1440 if (VM::loaded()) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected