1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/autoStopCluster.R
\name{autoStopCluster}
\alias{autoStopCluster}
\title{Automatically Stop a Cluster when Garbage Collected}
\usage{
autoStopCluster(cl, debug = FALSE)
}
\arguments{
\item{cl}{A cluster object created by for instance \code{\link[=makeClusterPSOCK]{makeClusterPSOCK()}}
or \code{\link[parallel:makeCluster]{parallel::makeCluster()}}.}
\item{debug}{If TRUE, then debug messages are produced when
the cluster is garbage collected.}
}
\value{
The cluster object with attribute \code{gcMe} set.
}
\description{
Registers a finalizer to a cluster such that the cluster will
be stopped when garbage collected
}
\details{
The cluster is stopped using
\code{\link[parallel:makeCluster]{stopCluster}(cl)}.
An alternative to explicitly call this function on an existing
\code{cluster} object, is to create the \code{cluster} object using
\code{makeClusterPSOCK()} with argument \code{autoStop = TRUE}.
}
\examples{
cl <- makeClusterPSOCK(2, dryrun = TRUE)
cl <- autoStopCluster(cl)
print(cl)
rm(list = "cl")
gc()
}
|