From e4b8bb208d74af08666d80ff94ddb5fe8c1433e5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 23 Jun 2023 11:36:26 +0200 Subject: Tune Windows fdselect() implementation --- libbutl/fdstream.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'libbutl') diff --git a/libbutl/fdstream.cxx b/libbutl/fdstream.cxx index 18f611f..8098e50 100644 --- a/libbutl/fdstream.cxx +++ b/libbutl/fdstream.cxx @@ -34,6 +34,7 @@ # include // wcsncmp(), wcsstr() +# include // this_thread::yield() # include // count() #endif @@ -2064,7 +2065,9 @@ namespace butl // Use exponential backoff but not too aggressive and with 25ms max. // - DWORD t (static_cast (i >= 100 ? 25 : 1 + (i / 4))); + DWORD t ( + static_cast (i <= 1000 ? 0 : + i >= 1000 + 100 ? 25 : 1 + ((i - 1000) / 4))); if (timeout) { @@ -2081,7 +2084,10 @@ namespace butl break; } - Sleep (t); + if (t == 0) + this_thread::yield (); + else + Sleep (t); } return make_pair (r, 0); -- cgit v1.1