Skip to content

Commit 9bb85fe

Browse files
BETA: It is now possible to signal absolute progress, e.g. p(step = 42) [#110]
1 parent 7cc8c9f commit 9bb85fe

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

NEWS

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ NEW FEATURES:
2525
* Add handlers("rstudio") to report on progress in the RStudio Console via
2626
the RStudio Job interface.
2727

28+
BETA FEATURES:
29+
30+
* As an alternative to specifying the relative amount of progress, say,
31+
p(amount = 2), it is now possible to also specify the absolute amount of
32+
progress made this far, e.g. p(step = 42). Argument 'amount' has not
33+
effect when argument 'step' is specfied. WARNING: Argument `step` should
34+
only be used when in full control of the order when this progression
35+
condition is signaled. For example, it must not be signaled as one of many
36+
parallel progress updates signaled concurrently, because we cannot guarantee
37+
the order these progressions arrive.
38+
2839
BUG FIXES:
2940

3041
* In progressr 0.7.0, any attempt to use more than one progressor inside a

R/make_progression_handler.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,11 @@ make_progression_handler <- function(name, reporter = list(), handler = NULL, en
390390
if (debug) message("- cannot 'update' handler, because it is not active")
391391
return(invisible(finished))
392392
}
393-
if (debug) mstr(list(step=step, "p$amount"=p[["amount"]], max_steps=max_steps))
393+
if (debug) mstr(list(step=step, "p$amount"=p[["amount"]], "p$step"=p[["step"]], max_steps=max_steps))
394+
if (!is.null(p[["step"]])) {
395+
## Infer effective 'amount' from previous 'step' and p$step
396+
p[["amount"]] <- p[["step"]] - step
397+
}
394398
step <<- min(max(step + p[["amount"]], 0L), max_steps)
395399
stop_if_not(step >= 0L)
396400
msg <- conditionMessage(p)

R/progression.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
#'
1111
#' @param amount (numeric) The total amount of progress made.
1212
#'
13-
#' @param step (character or integer) The step completed.
13+
#' @param step (numeric) The step completed. If specified, `amount` is ignored.
14+
#' _WARNING: Argument `step` should only be used when in full control of the
15+
#' order when this progression condition is signaled._ For example, it must not
16+
#' be signaled as one of many parallel progress updates signaled concurrently,
17+
#' because then we cannot guarantee the order these progressions arrive.
1418
#'
1519
#' @param time (POSIXct) A timestamp.
1620
#'

man/progression.Rd

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)