% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{setup_foreach}
\alias{setup_foreach}
\title{Set up a foreach parallel backend}
\usage{
setup_foreach(parallel, n_cores)
}
\arguments{
\item{parallel}{Logical; whether parallelism is requested.}

\item{n_cores}{Integer or \code{NULL}.  When \code{parallel = TRUE} and
\code{n_cores} is \code{NULL}, one fewer than the number of detected
cores is used (minimum 1).}
}
\value{
A list with:
\describe{
  \item{\code{op}}{The foreach binary operator (\code{\%do\%} or
    \code{\%dopar\%}).}
  \item{\code{cleanup}}{A zero-argument function that stops any cluster
    created here and re-registers the sequential backend.}
}
}
\description{
Registers a \pkg{doParallel} backend when requested and returns the
appropriate foreach binary operator together with a cleanup function.
}
\keyword{internal}
