MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / keep_alive

Function keep_alive

examples/server/httplib.h:2569–2586  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2567#endif
2568
2569inline bool keep_alive(socket_t sock, time_t keep_alive_timeout_sec) {
2570 using namespace std::chrono;
2571 auto start = steady_clock::now();
2572 while (true) {
2573 auto val = select_read(sock, 0, 10000);
2574 if (val < 0) {
2575 return false;
2576 } else if (val == 0) {
2577 auto current = steady_clock::now();
2578 auto duration = duration_cast<milliseconds>(current - start);
2579 auto timeout = keep_alive_timeout_sec * 1000;
2580 if (duration.count() > timeout) { return false; }
2581 std::this_thread::sleep_for(std::chrono::milliseconds(1));
2582 } else {
2583 return true;
2584 }
2585 }
2586}
2587
2588template <typename T>
2589inline bool

Callers 1

Calls 2

select_readFunction · 0.85
countMethod · 0.45

Tested by

no test coverage detected