Help us shape the future of Go! Take the 2026 Go Developer Survey

concurrent

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Task

type Task struct {
	Process string        // Process name (e.g. "scripts.runtime.basic.Hello")
	Args    []interface{} // Process arguments
	Timeout int           // Timeout in seconds (0 = use default 30s)
}

Task represents a single process call to execute concurrently.

func ParseTasks

func ParseTasks(info *v8go.FunctionCallbackInfo) ([]Task, *bridge.Share, error)

ParseTasks extracts a []Task from the first JS argument (an array of {process, args} objects). Returns nil and an error string if parsing fails.

type TaskResult

type TaskResult struct {
	Data  interface{} `json:"data"`            // Return value on success
	Error string      `json:"error,omitempty"` // Error message on failure
	Index int         `json:"index"`           // Original task index (preserves order)
}

TaskResult holds the outcome of a single concurrent task.

func ParallelAll

func ParallelAll(tasks []Task, share *bridge.Share) []TaskResult

ParallelAll executes all tasks concurrently and waits for every task to complete. Semantics: Promise.all — all results returned, order preserved.

func ParallelAny

func ParallelAny(tasks []Task, share *bridge.Share) []TaskResult

ParallelAny executes all tasks concurrently and returns once the first task succeeds. Semantics: Promise.any — first success wins; all tasks still run to completion to avoid leaks. A "success" is defined as data != nil and error == "".

func ParallelRace

func ParallelRace(tasks []Task, share *bridge.Share) []TaskResult

ParallelRace executes all tasks concurrently and returns once the first task completes. Semantics: Promise.race — first completion wins (success or failure).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL