|
36 | 36 | #' own independent set of daemons. `NULL` (default) uses the 'default' |
37 | 37 | #' profile. |
38 | 38 | #' |
39 | | -#' @return A 'mirai' object. |
| 39 | +#' @return For [mirai()]: a 'mirai' object. |
| 40 | +#' |
| 41 | +#' For [try_mirai()]: a 'mirai' object, or `NULL` (invisibly) if the |
| 42 | +#' dispatcher's `capacity` budget is exhausted at the time of submission. |
40 | 43 | #' |
41 | 44 | #' @section Evaluation: |
42 | 45 | #' |
@@ -151,24 +154,20 @@ mirai <- function(.expr, ..., .args = list(), .timeout = NULL, .compute = NULL) |
151 | 154 |
|
152 | 155 | #' @rdname mirai |
153 | 156 | #' |
154 | | -#' @details |
| 157 | +#' @section Capacity: |
155 | 158 | #' |
156 | | -#' [try_mirai()] is a non-blocking variant of [mirai()] for use in event-loop |
157 | | -#' contexts (Shiny, promises) where the host R thread cannot afford to wait |
158 | | -#' for the dispatcher's `capacity` budget to drain. It returns `NULL` |
159 | | -#' (invisibly) immediately if the queue is at capacity at the time of |
160 | | -#' submission, instead of blocking. Where there is no gate to consult (no |
161 | | -#' dispatcher, or `capacity` unset), it always returns a 'mirai' — the |
162 | | -#' contract is "don't block on queue pressure", not "fail when the queue is |
163 | | -#' empty". |
| 159 | +#' The `capacity` argument to [daemons()] caps the queued task payload at |
| 160 | +#' dispatcher (in MB), preventing host out-of-memory. [mirai()] blocks the |
| 161 | +#' calling R thread on submission until queued bytes drop below this budget. |
164 | 162 | #' |
165 | | -#' Pair with a backpressure policy of your choice — drop, retry, signal |
166 | | -#' upstream — by checking for `NULL`. |
| 163 | +#' [try_mirai()] is a non-blocking variant for event-loop contexts (Shiny, |
| 164 | +#' promises) where the host R thread cannot afford to wait. It returns `NULL` |
| 165 | +#' (invisibly) immediately if the queue is at capacity, instead of blocking. |
| 166 | +#' With no dispatcher, or `capacity` unset, [try_mirai()] always returns a |
| 167 | +#' 'mirai' — the contract is "don't block on queue pressure". Check for a `NULL` |
| 168 | +#' return value and handle accordingly — drop, retry, or signal upstream. |
167 | 169 | #' |
168 | | -#' @return For [mirai()]: a 'mirai' object. |
169 | | -#' |
170 | | -#' For [try_mirai()]: a 'mirai' object, or `NULL` (invisibly) if the |
171 | | -#' dispatcher's `capacity` budget is exhausted at the time of submission. |
| 170 | +#' Use [capacity()] to inspect current and peak queue usage. |
172 | 171 | #' |
173 | 172 | #' @examplesIf interactive() |
174 | 173 | #' # non-blocking submission - caller handles backpressure |
|
0 commit comments