1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
//! # Trash Parallelism
//!
//! A high-performance Rust library providing comprehensive async, threading,
//! memory management, and utility functions for building efficient applications.
//!
//! ## Overview
//!
//! Trash Parallelism is a batteries-included Rust library designed for high-performance
//! applications requiring efficient async operations, parallel processing, memory management,
//! and system-level utilities. Built with performance and ergonomics in mind.
//!
//! ## Key Features
//!
//! - **🚀 Async Operations**: High-performance async utilities with smol, futures-lite, and crossfire
//! - **⚡ Threading**: Parallel processing with work-stealing schedulers and fork-join patterns
//! - **💾 Memory Management**: Efficient allocation with mimalloc and custom memory pools
//! - **📡 Channels**: Advanced channel communication with monitoring and serialization
//! - **🖥️ System Utilities**: Time handling, environment variables, file system operations
//! - **📊 Data Processing**: Parsing, serialization, and data manipulation
//! - **🔄 I/O Operations**: File and network I/O with async support
//! - **📝 Logging**: Structured logging with performance monitoring
//! - **🛠️ Utilities**: Compression, hashing, JSON handling, and more
//!
//! ## Quick Start
//!
//! ### Basic Usage
//! ```rust
//! use trash_utilities::*;
//!
//! // Async task spawning
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! spawn_task!("my_task", async {
//! println!("Hello from async task!");
//! Ok(())
//! });
//! # Ok(())
//! # }
//!
//! // Parallel processing
//! let data = vec![1, 2, 3, 4, 5];
//! let result = parallel_map(data, |x| x * 2);
//! assert_eq!(result, vec![2, 4, 6, 8, 10]);
//!
//! // System utilities
//! let now = current_utc_time();
//! let home = read_env_var("HOME").unwrap_or_default();
//! println!("Current time: {}, Home: {}", now, home);
//! # }
//! ```
//!
//! ### Advanced Example: High-Performance Data Processing
//! ```rust,no_run
//! use trash_utilities::*;
//! use smol;
//!
//! # smol::block_on(async {
//! // Parallel data processing pipeline
//! let raw_data = vec![1u32; 10000];
//!
//! // Process in parallel
//! let processed = parallel_map(raw_data, |x| x * x + 1);
//!
//! // Serialize to JSON asynchronously
//! let json_data = serde::serialize_to_json(&processed).unwrap();
//!
//! // Compress and save
//! let compressed = io::utils::compress_data_brotli(json_data.as_bytes(), 6).await.unwrap();
//! io::utils::write_file_async("processed_data.gz", &compressed).await.unwrap();
//!
//! println!("Processed {} elements", processed.len());
//! # });
//! ```
//!
//! ### Memory Management Example
//! ```rust
//! use trash_utilities::memory::*;
//!
//! // Custom memory pool allocation
//! let pool_name = "processing_pool";
//! create_memory_pool(pool_name, 1024 * 1024).unwrap(); // 1MB pool
//!
//! // Allocate from pool
//! let ptr = alloc_from_pool!(pool_name, 1024).unwrap();
//!
//! // Use allocated memory safely
//! unsafe {
//! std::ptr::write_bytes(ptr, 0, 1024); // Initialize to zero
//! }
//!
//! // Pool automatically manages cleanup
//! ```
//!
//! ### Channel-Based Communication
//! ```rust,no_run
//! use trash_utilities::channels::*;
//! use smol;
//!
//! # smol::block_on(async {
//! // Create monitored channel
//! let (tx, rx, monitor) = create_monitored_channel::<String>(10);
//!
//! // Send messages
//! for i in 0..5 {
//! send_async(&tx, format!("Message {}", i)).await.unwrap();
//! }
//!
//! // Receive and process
//! for _ in 0..5 {
//! let msg = recv_async(&rx).await.unwrap();
//! println!("Received: {}", msg);
//! }
//!
//! // Check performance stats
//! let stats = monitor.get_stats();
//! println!("Processed {} messages", stats.messages_sent);
//! # });
//! ```
//!
//! ## Module Organization
//!
//! ### Core Functionality
//! - **[`async`]**: Comprehensive async utilities with smol runtime
//! - **[`parallel`]**: Threading and parallelism with work-stealing
//! - **[`memory`]**: Memory management and custom pools
//! - **[`channels`]**: Advanced channel communication
//!
//! ### Data & I/O
//! - **[`serde`]**: Serialization utilities (JSON, base64, etc.)
//! - **[`io`]**: Async file operations and compression
//! - **[`data`]**: Data parsing and manipulation
//! - **[`chars`]**: String processing and encoding
//!
//! ### System Integration
//! - **[`sys`]**: System utilities (time, env vars, filesystem)
//! - **[`common`]**: Shared utilities across modules
//!
//! ## Performance Characteristics
//!
//! - **Zero-Copy Operations**: Where possible, avoids unnecessary allocations
//! - **Async-First Design**: Built for non-blocking I/O and concurrency
//! - **Memory Efficient**: Custom allocators and pooling reduce overhead
//! - **Parallel Processing**: Automatic parallelization for CPU-bound tasks
//! - **Monitoring**: Built-in performance tracking and statistics
//!
//! ## Safety & Reliability
//!
//! - **Memory Safe**: All operations are memory-safe with no undefined behavior
//! - **Thread Safe**: Concurrent operations are properly synchronized
//! - **Error Handling**: Comprehensive error propagation with context
//! - **Resource Management**: Automatic cleanup and RAII patterns
//! - **Testing**: Extensive test coverage for reliability
// Re-exports
pub use ;
pub use ;