Add corex library with resource-aware execution primitives
- Implement CI workflow for formatting, linting, testing, and documentation checks. - Create publish workflow for automated publishing to crates.io. - Add .gitignore to exclude build artifacts and editor files. - Define Cargo.toml for corex and corex-core with dependencies and metadata. - Add README.md files for corex and corex-core with usage instructions and licensing. - Implement core execution primitives: spawn_io, compute, and spawn_bg with panic isolation. - Establish global engine context for resource management based on logical CPU cores. - Introduce error handling for compute panics.
This commit is contained in:
+39
@@ -0,0 +1,39 @@
|
||||
//! # corex
|
||||
//!
|
||||
//! Resource-aware abstractions for async I/O, heavy compute, and
|
||||
//! background queue management, built on a single lazily-initialized
|
||||
//! global engine context.
|
||||
//!
|
||||
//! Call [`init`] once at startup (or simply let the first call to any
|
||||
//! entry point below trigger it lazily) and then use whichever of the
|
||||
//! feature-gated entry points your workload needs:
|
||||
//!
|
||||
//! - [`spawn_io`] (feature `io`) — spawn an async I/O task, tracing-instrumented.
|
||||
//! - [`compute`] (feature `compute`) — run CPU-bound work on a sized Rayon pool, panic-isolated.
|
||||
//! - [`spawn_bg`] (feature `bg`) — spawn a background task under bounded concurrency.
|
||||
//!
|
||||
//! Enable the `full` feature to pull in all three at once.
|
||||
|
||||
pub use corex_core::context::{context, EngineContext};
|
||||
|
||||
#[cfg(feature = "compute")]
|
||||
pub use corex_core::error::CorexError;
|
||||
|
||||
#[cfg(feature = "io")]
|
||||
pub use corex_core::io::spawn_io;
|
||||
|
||||
#[cfg(feature = "compute")]
|
||||
pub use corex_core::compute::compute;
|
||||
|
||||
#[cfg(feature = "bg")]
|
||||
pub use corex_core::bg::spawn_bg;
|
||||
|
||||
/// Bootstraps the global corex [`EngineContext`].
|
||||
///
|
||||
/// See [`corex_core::context::init`] for full semantics: this is safe to
|
||||
/// call any number of times, from any thread, and is equivalent to letting
|
||||
/// the first call to [`spawn_io`], [`compute`], or [`spawn_bg`] trigger
|
||||
/// initialization implicitly.
|
||||
pub fn init() -> &'static EngineContext {
|
||||
corex_core::context::init()
|
||||
}
|
||||
Reference in New Issue
Block a user