the exponential backoff of a waiting thread: \( 2^k \) pauses at the \( k \)-th call up to \( S \), then a yield to the system
More...
#include <ADS/concurrent/Backoff.h>
|
| | Backoff (int S=6) |
| | the backoff that spins on the first \( S + 1 \) calls
|
| void | pause (void) noexcept |
| | waits a little: \( 2^k \) pauses of the processor at the call \( k \) from the last reset() if \( k \le S \), a yield of the thread otherwise
|
| void | reset (void) noexcept |
| | starts again from one pause
|
| bool | spinning (void) const noexcept |
| | whether the next pause() spins, i.e., \( k \le S \)
|
| int | step (void) const noexcept |
| | the calls of pause() since the last reset() that spun, \( k \)
|
the exponential backoff of a waiting thread: \( 2^k \) pauses at the \( k \)-th call up to \( S \), then a yield to the system
◆ Backoff()
| ADS::Backoff::Backoff |
( |
int | S = 6 | ) |
|
|
inlineexplicit |
the backoff that spins on the first \( S + 1 \) calls
- Precondition
- \( 0 \le S \le 16 \)
◆ pause()
| void ADS::Backoff::pause |
( |
void | | ) |
|
|
inlinenoexcept |
waits a little: \( 2^k \) pauses of the processor at the call \( k \) from the last reset() if \( k \le S \), a yield of the thread otherwise
In pseudocode (Anderson, beyond the book):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{procedure}\ \mathrm{pause}() \cr
2 & \quad \textbf{if}\ k \le S\ \textbf{then} \cr
3 & \qquad \textbf{for}\ i \gets 1\ \textbf{to}\ 2^k\ \textbf{do}
\ \text{a pause of the processor} \cr
4 & \qquad k \gets k + 1 \cr
5 & \quad \textbf{else}\ \text{yield the processor}
\end{array}}
\]
◆ reset()
| void ADS::Backoff::reset |
( |
void | | ) |
|
|
inlinenoexcept |
starts again from one pause
◆ spinning()
| bool ADS::Backoff::spinning |
( |
void | | ) |
const |
|
inlinenodiscardnoexcept |
whether the next pause() spins, i.e., \( k \le S \)
◆ step()
| int ADS::Backoff::step |
( |
void | | ) |
const |
|
inlinenodiscardnoexcept |
The documentation for this class was generated from the following file: