@@ -26,30 +26,30 @@ static _LIBCPP_CONSTEXPR const int __libcpp_polling_count = 64;
26
26
// Polls a thread for a condition given by a predicate, and backs off based on a backoff policy
27
27
// before polling again.
28
28
//
29
- // - __f is the "test function" that should return true if polling succeeded, and false if it failed.
29
+ // - __poll is the "test function" that should return true if polling succeeded, and false if it failed.
30
30
//
31
- // - __bf is the "backoff policy", which is called with the duration since we started polling. It should
31
+ // - __backoff is the "backoff policy", which is called with the duration since we started polling. It should
32
32
// return false in order to resume polling, and true if polling should stop entirely for some reason.
33
33
// In general, backoff policies sleep for some time before returning control to the polling loop.
34
34
//
35
35
// - __max_elapsed is the maximum duration to try polling for. If the maximum duration is exceeded,
36
36
// the polling loop will return false to report a timeout.
37
- template <class _Fn , class _BFn >
37
+ template <class _Poll , class _Backoff >
38
38
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_poll_with_backoff (
39
- _Fn && __f, _BFn && __bf , chrono::nanoseconds __max_elapsed = chrono::nanoseconds::zero()) {
39
+ _Poll && __poll, _Backoff && __backoff , chrono::nanoseconds __max_elapsed = chrono::nanoseconds::zero()) {
40
40
auto const __start = chrono::high_resolution_clock::now ();
41
41
for (int __count = 0 ;;) {
42
- if (__f ())
43
- return true ; // _Fn completion means success
42
+ if (__poll ())
43
+ return true ; // __poll completion means success
44
44
if (__count < __libcpp_polling_count) {
45
45
__count += 1 ;
46
46
continue ;
47
47
}
48
48
chrono::nanoseconds const __elapsed = chrono::high_resolution_clock::now () - __start;
49
49
if (__max_elapsed != chrono::nanoseconds::zero () && __max_elapsed < __elapsed)
50
50
return false ; // timeout failure
51
- if (__bf (__elapsed))
52
- return false ; // _BFn completion means failure
51
+ if (__backoff (__elapsed))
52
+ return false ; // __backoff completion means failure
53
53
}
54
54
}
55
55
0 commit comments