% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pool.R
\name{pool_create}
\alias{pool_create}
\title{Create a Worker Pool}
\usage{
pool_create(
  n = parallel::detectCores() - 1L,
  rss_limit = "2GB",
  rss_drift_threshold = 0.5,
  heartbeat_interval = 5,
  min_recycle_interval = 1,
  init_expr = NULL,
  packages = NULL
)
}
\arguments{
\item{n}{Integer. Number of worker processes to spawn.}

\item{rss_limit}{Numeric or character. Maximum RSS per worker before recycling.
Can be bytes (numeric) or human-readable (e.g., "2GB"). Default is "2GB".}

\item{rss_drift_threshold}{Numeric. Fraction of RSS increase from baseline
that triggers recycling (default 0.5 = 50\% growth).}

\item{heartbeat_interval}{Numeric. Seconds between health checks (default 5).}

\item{min_recycle_interval}{Numeric. Minimum time in seconds between recycling
the same worker (default 1.0). This prevents thrashing PSOCK worker creation
under extremely tight RSS limits.}

\item{init_expr}{Expression to evaluate in each worker on startup.}

\item{packages}{Character vector. Packages to load in workers.}
}
\value{
A \code{shard_pool} object (invisibly). The pool is also stored in the
package environment for reuse.
}
\description{
Spawns N R worker processes that persist across multiple \code{shard_map()} calls.
Workers are supervised and recycled when RSS drift exceeds thresholds.
}
\examples{
\donttest{
p <- pool_create(2)
pool_stop(p)
}
}
