run_parallel: Run a parallel computation using either "parallel" or...

View source: R/parallel_helpers.R

run_parallelR Documentation

Run a parallel computation using either "parallel" or "future"

Description

Small wrapper that hides the branching between the two back-ends. It always returns a **named list** whose names are identical to the names of the input split list. This guarantees that 'unlist()' produces the same named vector for both back-ends, which is required by the unit tests.

Usage

run_parallel(
  X,
  FUN,
  backend = c("parallel", "future"),
  use_threads = NULL,
  cl = NULL,
  ...
)

Arguments

X

List (or vector) of inputs that will be split among the workers.

FUN

Function that will be executed on each chunk.

backend

Either "parallel" or "future".

use_threads

Number of workers (relevant for both back-ends).

cl

Optional cluster object created with parallel::makeCluster(). Only required when using the "parallel" backend on Windows, where parallel::parLapply() is used. Ignored on Unix-like systems where parallel::mclapply() is available.

Value

List of results (identical to the output of 'parLapply' / 'future_lapply'). The list is **named** - the names are taken from the split index ('split_idx').


TesiproV documentation built on Oct. 28, 2026, 5:13 p.m.