Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Native Executor
A high-performance, platform-native async task executor for Rust that leverages operating system primitives for optimal performance and integration.
Features
- ๐ Platform-native execution: Leverages Apple's Grand Central Dispatch (GCD) on macOS/iOS for optimal performance
- ๐ Async/await support: Fully compatible with Rust's async/await syntax and ecosystem
- ๐งต Thread-safe tasks: Safe concurrent execution across thread boundaries with
Task<T>
- ๐ Thread-local tasks: Efficient thread-local execution with
LocalTask<T>
- ๐ Priority control: Fine-grained task execution priority management
- โฑ๏ธ Timer utilities: High-precision timers and sleep functionality with fluent API
- ๐ Thread-safety utilities:
LocalValue<T>
,OnceValue<T>
, andMainValue<T>
for controlled thread access patterns - ๐ฆ
#[no_std]
compatible: Works in embedded and resource-constrained environments - ๐ฏ Zero-cost abstractions: Minimal overhead over native platform APIs
Installation
Add this to your Cargo.toml
:
[]
= "0.1.0"
Quick Start
use ;
use Duration;
Core Components
Task Spawning
The library provides flexible task spawning with different execution contexts:
use ;
// Simple task spawning with default priority
let task_handle = task;
// Task with explicit priority control
let background_task = with_priority;
// Task guaranteed to run on the main thread
let ui_task = on_main;
Timer Utilities
High-precision timing with platform-native scheduling:
use ;
use Duration;
async
Thread-safety Utilities
Specialized containers for different thread-safety requirements:
LocalValue
Thread-local values that enforce single-thread access:
use LocalValue;
let local = new;
assert_eq!; // โ
OK on the same thread
// โ Access from another thread would panic for safety
OnceValue
Values that can be consumed exactly once:
use OnceValue;
let once = new;
assert_eq!; // โ
Read access
let value = once.take; // โ
Take ownership
// โ once.get() would now panic - value consumed
MainValue
Cross-thread safe values with main-thread access:
use MainValue;
let ui_element = new;
// Safe cross-thread access - execution happens on main thread
let length = ui_element.handle.await;
assert_eq!;
Platform Support
Current Support
- Apple Platforms (macOS, iOS, tvOS, watchOS): Full support via Grand Central Dispatch (GCD)
- Leverages system-level thread pools and scheduling
- Priority mapping to GCD queue priorities
- Optimal performance and system integration
Planned Support
- Windows: Native thread pool and completion ports integration
- Linux: epoll and io_uring based implementation
- Android: Android-specific optimizations
- WebAssembly: Browser and WASI runtime support
Each platform implementation leverages native OS primitives for maximum performance.
Examples
Explore comprehensive usage examples in the examples directory:
- Simple Task: Basic task spawning and execution
- Timers: Timer utilities and sleep functionality
- Priority Control: Task priority management
- Main Thread: Main thread execution patterns
- Thread-Local Values: Thread-local and once-value containers
Run any example with:
License
This project is licensed under the MIT License - see the LICENSE file for details.