Building a pyramid runs in parallel. a5pyramid_threads() reports the
number of threads builds use by default, and a5pyramid_threads(n) sets
it for the session. As with options() and a5R::a5_threads(),
setting returns the previous value, so with(a5pyramid_threads(2), expr)
runs expr on two threads and then restores the setting, even if expr
fails. The threads argument of a5_pyramid() and a5_write_pyramid()
overrides it for one call.
Usage
a5pyramid_threads(n = NULL)
# S3 method for class 'a5pyramid_threads'
with(data, expr, ...)Value
a5pyramid_threads(): the current count, an integer.
a5pyramid_threads(n): the previous setting, invisibly, as an
a5pyramid_threads object. with(): the value of expr.
Details
The default is resolved in this order: the option a5pyramid.threads,
the environment variable A5PYRAMID_THREADS, then every CPU available to
the R process (which respects affinity masks and container CPU quotas).
The count is independent of a5R::a5_threads(). Results do not depend
on it.
Examples
a5pyramid_threads()
#> [1] 4
old <- a5pyramid_threads(2)
a5pyramid_threads()
#> [1] 2
a5pyramid_threads(old) # restore
with(a5pyramid_threads(1), a5pyramid_threads())
#> [1] 1
