Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Ray project Ray ConcurrencyGroupBuilder

From Leeroopedia
Knowledge Sources
Domains Distributed_Computing, Java_API
Last Updated 2026-02-13 16:00 GMT

Overview

Concrete builder for constructing ConcurrencyGroup instances provided by the Ray Java API.

Description

ConcurrencyGroupBuilder<A> extends BaseConcurrencyGroupBuilder<A> and provides a fluent API for creating concurrency groups with a name, maximum concurrency level, and a list of associated actor methods. It collects function references into a list via internalAddMethod() and delegates to Ray.internal().createConcurrencyGroup() when build() is called.

Usage

Use this builder when you need to programmatically create concurrency groups that control how many actor methods can execute concurrently within a single actor. Concurrency groups allow different methods on the same actor to have different concurrency limits.

Code Reference

Source Location

  • Repository: Ray
  • File: java/api/src/main/java/io/ray/api/concurrencygroup/ConcurrencyGroupBuilder.java

Signature

public class ConcurrencyGroupBuilder<A> extends BaseConcurrencyGroupBuilder<A> {
    public ConcurrencyGroupBuilder<A> setName(String name);
    public ConcurrencyGroupBuilder<A> setMaxConcurrency(int maxConcurrency);
    public ConcurrencyGroup build();
    protected ConcurrencyGroupBuilder<A> internalAddMethod(RayFunc func);
}

Import

import io.ray.api.concurrencygroup.ConcurrencyGroupBuilder;

I/O Contract

Inputs

Name Type Required Description
name String Yes Name of the concurrency group
maxConcurrency int Yes Maximum number of concurrent method executions
func RayFunc No Actor method to add to the group (via inherited addMethod)

Outputs

Name Type Description
concurrencyGroup ConcurrencyGroup The constructed concurrency group instance

Usage Examples

// Create a concurrency group for I/O-bound methods
ConcurrencyGroup ioGroup = new ConcurrencyGroupBuilder<MyActor>()
    .setName("io-group")
    .setMaxConcurrency(10)
    .addMethod(MyActor::readFile)
    .addMethod(MyActor::writeFile)
    .build();

// Use the concurrency group when creating an actor
ActorHandle<MyActor> actor = Ray.actor(MyActor::new)
    .setConcurrencyGroups(ioGroup)
    .remote();

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment