|
1 | 1 | //! # Relay Threading
|
2 | 2 | //!
|
3 |
| -//! This module provides threading abstractions for Relay, offering a set of utilities for managing |
4 |
| -//! asynchronous work. It includes a thread-based asynchronous task pool, a flexible builder for |
5 |
| -//! configuring pool parameters (thread naming, panic handling, concurrency limits), and mechanisms for |
6 |
| -//! multiplexing tasks across dedicated threads with built-in panic recovery. |
7 |
| -//! |
8 |
| -//! ## Features |
9 |
| -//! |
10 |
| -//! - **AsyncPool**: A thread-based asynchronous pool for executing futures concurrently on dedicated threads. |
11 |
| -//! - **AsyncPoolBuilder**: A configurable builder to construct an [`AsyncPool`] with custom settings, |
12 |
| -//! including thread naming, panic handlers (for both threads and tasks), custom spawn handlers, and |
13 |
| -//! concurrency limits. |
14 |
| -//! - **Multiplexed Execution**: A task multiplexer that drives a collection of asynchronous tasks while |
15 |
| -//! respecting a specified concurrency limit. It handles panics gracefully via an optional panic callback. |
16 |
| -//! - **Custom Thread Spawning**: Supports customized thread creation, allowing usage of system defaults or |
17 |
| -//! custom configurations through a provided spawn handler. |
| 3 | +//! This module provides a robust threading framework for Relay, designed to efficiently manage and execute |
| 4 | +//! asynchronous workloads. At its core is a thread-based asynchronous task pool that offers: |
| 5 | +//! |
| 6 | +//! - **Flexible Configuration**: Fine-tune thread counts, naming patterns, panic handling strategies, |
| 7 | +//! and concurrency limits through a builder pattern. |
| 8 | +//! - **Task Multiplexing**: Distribute tasks across dedicated worker threads. |
| 9 | +//! - **Panic Recovery**: Built-in mechanisms to gracefully handle and recover from panics, both at the |
| 10 | +//! thread and individual task level |
| 11 | +//! - **Tokio Integration**: Seamlessly integrates with Tokio runtime for async task execution |
| 12 | +//! |
| 13 | +//! ## Concurrency Model |
| 14 | +//! |
| 15 | +//! The pool maintains a set of dedicated worker threads, each capable of executing multiple async tasks |
| 16 | +//! concurrently up to a configurable limit. This architecture ensures efficient resource utilization |
| 17 | +//! while preventing any single thread from becoming overwhelmed. |
| 18 | +//! |
| 19 | +//! The pool maintains a bounded queue with a capacity of twice the number of worker threads. This |
| 20 | +//! design allows new tasks to be queued while existing ones are being processed, ensuring smooth |
| 21 | +//! task handoff between producers and consumers. The bounded nature of the queue provides natural |
| 22 | +//! backpressure - when workers are overwhelmed, task submission will block until capacity becomes |
| 23 | +//! available, preventing resource exhaustion. |
18 | 24 | //!
|
19 | 25 | //! ## Modules
|
20 | 26 | //!
|
|
0 commit comments