Description Usage Arguments Details See Also Examples
The startWorkers
function is used to start a specified number of
workers to execute tasks in parallel. The stopWorkers
function
is used to shutdown the workers in the specified worker group object.
1 2 3 | startWorkers(workerCount=getOption('cores'), FORCE=FALSE,
tmpdir=tempdir(), verbose=FALSE)
stopWorkers(obj)
|
workerCount |
The number of worker processes to start on the local machine.
The default is the value of |
FORCE |
A logical value indicating whether another worker group should be stopped in order to allow this group to be started. This is useful if previous sessions were started, but not stopped properly. |
tmpdir |
The path of a directory in which to create temporary files. |
verbose |
A logical value indicating whether verbose messages should be displayed. |
obj |
The worker group object to stop. |
The startWorkers
function returns a "worker group" object, which
represents the workers to evaluate tasks. That object is passed to the
registerDoSMP
function for use by the foreach
function.
It is important to subsequently call the stopWorkers
function,
or the workers won't be stopped, but will keep running after your R session
exits. System IPC resources will also be retained. This will cause
subsequent calls to startWorkers
to issue warning and error messages.
IPC resources can be deleted using the rmSessions
function.
1 2 3 4 5 | # start two workers, compute some square roots, and shutdown
w <- startWorkers(2)
registerDoSMP(w)
foreach(i=1:3) %dopar% sqrt(i)
stopWorkers(w)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.