Function retryFor

Retry the 'check' condition until it is true, or the timeout expires.

void retryFor (
  lazy bool check,
  core.time.Duration timeout,
  lazy string msg = "",
  string file = __FILE__,
  ulong line = cast(ulong)__LINE__
);

This is a test-only utility, as it will sleep the main thread for 100 msecs between each re-try. Retry utilities should use TaskManager.sleep for sleep as it will yield the task but not block the thread.

If the timeout expires, and the 'check' condition is still false, it throws an AssertError, which is an unrecoverable error.

Parameters

NameDescription
Exc a custom exception type, in case we want to catch it
check the condition to check on
timeout time to wait for the check to succeed
msg optional AssertException message when the condition fails after the timeout expires
file file from the call site
line line from the call site

Throws

AssertError if the timeout is reached and the condition still fails