async (version 0.0.0.9004)

async_until: Repeatedly call task until it its test function returns TRUE

Description

Repeatedly call task until it its test function returns TRUE

Usage

async_until(test, task, ...)

Arguments

test

Synchronous test function.

task

Asynchronous function to call repeatedly.

...

Arguments to pass to task.

Value

Deferred value, that is resolved when the iteration is done.

See Also

Other async control flow: async_reflect, async_retryable, async_retry, async_sequence, async_try_each, async_whilst

Examples

Run this code
# NOT RUN {
## Keep calling until it "returns" a number less than < 0.1
calls <- 0
number <- Inf
synchronise(async_until(
  function() number < 0.1,
  function() {
    calls <<- calls + 1
    number <<- runif(1)
  }
))
calls
# }

Run the code above in your browser using DataLab