Utilities for Parallel Computations
ts_eval
generates a thread safe version of
eval
. It uses boost mutexes provided by the
synchronicity package. The generated function has
arguments expr
and envir
, which are passed
to eval
.
ts_tempfile
generates a unique temporary
filename that includes the name of the host machine
and/or the caller's process id, so that it is thread
safe.
hostfile
generates a temporary filename composed
with the name of the host machine and/or the current
process id.
gVariable
generates a function that access a
global static variable, possibly in shared memory (only
for numeric matrix-coercible data in this case). It is
used primarily in parallel computations, to preserve data
accross computations that are performed by the same
process.
ts_eval(mutex = synchronicity::boost.mutex(),
verbose = FALSE) ts_tempfile(pattern = "file", ..., host = TRUE,
pid = TRUE)
hostfile(pattern = "file", tmpdir = tempdir(),
fileext = "", host = TRUE, pid = TRUE)
gVariable(init, shared = FALSE)
a mutex or a mutex descriptor. If missing, a new mutex is created via the function boost.mutex from the synchronicity package.
a logical that indicates if messages should be printed when locking and unlocking the mutex.
extra arguments passed to
tempfile
.
logical that indicates if the host machine name should be appear in the filename.
logical that indicates if the current process id be appear in the filename.
initial value
a logical that indicates if the variable should be stored in shared memory or in a local environment.
a non-empty character vector giving the initial part of the name.
a non-empty character vector giving the directory name
a non-empty character vector giving the file extension