Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(threading): Add new relay-threading module #4500

Merged
merged 11 commits into from
Feb 19, 2025

Conversation

iambriccardo
Copy link
Member

@iambriccardo iambriccardo commented Feb 18, 2025

This PR a new relay-threading package that provides a thread-based task execution framework for managing concurrent workloads in Relay.

Key Features

  • Async Task Pool: Thread-based pool for executing async tasks with configurable concurrency limits
  • Builder Pattern: Flexible configuration of thread counts, naming, and panic handling through AsyncPoolBuilder
  • Backpressure Control: Bounded task queue prevents resource exhaustion
  • Panic Recovery: Built-in handling for both thread and task-level panics
  • Tokio Integration: Seamless integration with Tokio runtime for async execution

Example Usage

let pool = AsyncPoolBuilder::new(runtime_handle)
    .num_threads(4)
    .max_concurrency(100)
    .build()
    .unwrap();

// Schedule a task
pool.spawn(async {
    // Task logic here
});

Testing

The package includes comprehensive tests covering:

  • Single and multi-threaded execution
  • Concurrent task handling
  • Panic recovery
  • Performance benchmarks for various thread/task

@iambriccardo iambriccardo marked this pull request as ready for review February 18, 2025 13:04
@iambriccardo iambriccardo requested a review from a team as a code owner February 18, 2025 13:04
@iambriccardo iambriccardo requested a review from Dav1dde February 19, 2025 09:44
@iambriccardo iambriccardo force-pushed the riccardo/feat/async-pool branch from 276844c to c0d03ed Compare February 19, 2025 09:47
@iambriccardo iambriccardo enabled auto-merge (squash) February 19, 2025 12:24
@iambriccardo iambriccardo merged commit 31f032a into master Feb 19, 2025
25 checks passed
@iambriccardo iambriccardo deleted the riccardo/feat/async-pool branch February 19, 2025 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants