Parallel Computations
Powerful Parallel Computing with BoxLang's Async Framework
Sequential: Task1 → Task2 → Task3 → Task4 (16 seconds)
🟦 🟦 🟦 🟦
Parallel: Task1 ↘
Task2 → Results (4 seconds)
Task3 ↗
Task4 ↙
🟦🟦🟦🟦🎯 Core Parallel Computing BIFs
BIF
Purpose
Input
Output
🚀 Basic Parallel Execution
asyncAll() - Execute All in Parallel
asyncAll() - Execute All in ParallelasyncAny() - Race to the Finish
asyncAny() - Race to the Finish🔄 Data Processing with asyncAllApply()
asyncAllApply()Array Processing
Struct Processing
With Error Handling
With Custom Executor and Timeout
🔢 Collection Parallel Methods
📋 Supported Collection Types
Type
Methods
🎯 Collection Method Purposes
Method
Purpose
Input
Output
Use Case
🔄 Each - Perform Actions
✅ Every - Validate All
🔍 Filter - Extract Matching Items
🔄 Map - Transform Items
❌ None - Ensure Absence
🔎 Some - Check Existence
🎛️ Parallel Execution Parameters
🔄 Array Parallel Processing
📝 List Parallel Processing
🗄️ Query Parallel Processing
🏗️ Struct Parallel Processing
🎯 Method-Specific Examples
Each - Side Effects
Each - Side EffectsEvery - Validation
Every - ValidationSome - Existence Check
Some - Existence CheckNone - Negative Validation
None - Negative Validation⚡ Performance Benefits
🌟 Virtual Threads: The Game Changer
🎯 When to Use Virtual Threads
🔄 Virtual Thread Examples
Network I/O Operations
Database Operations
File Processing
🆚 Virtual vs Platform Threads Comparison
Aspect
Platform Threads
Virtual Threads
📊 Performance Comparison
🎛️ Best Practices for Collection Parallel Processing
1. Choose Appropriate Thread Count
2. Use Parallel Processing for Right-Sized Collections
3. Expensive Operations Benefit Most
⚡ Single Async Operations
asyncRun() - Basic Async Execution
asyncRun() - Basic Async ExecutionfutureNew() - Creating Futures
futureNew() - Creating Futures🎛️ Advanced Patterns
Pipeline Processing
Fan-Out/Fan-In Pattern
Retry with Exponential Backoff
🛠️ Executor Management
Using Custom Executors
🚨 Thread Cancellation Control
📊 Performance Monitoring
Timing Parallel Operations
Memory and Resource Monitoring
🎯 Best Practices
✅ Do's
❌ Don'ts
🔗 Related Documentation
📈 Performance Comparison
Last updated
Was this helpful?
