Skip to content

Commit 809f51f

Browse files
committed
refactor: remove AsyncDecorator as it's an unnecessary abstraction
- Deleted async_decorator.hpp file - Removed all references to AsyncDecorator from codebase - Removed with_async() methods from IntegratorBuilder - Updated documentation to reflect the removal - Follows the philosophy: the best framework is no framework - Users should use std::async directly for async needs
1 parent 80cd49f commit 809f51f

File tree

9 files changed

+23
-436
lines changed

9 files changed

+23
-436
lines changed

ARCHITECTURE_TRANSFORMATION_SUMMARY.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Each facility focuses on **exactly one concern**:
4444
// ✅ GOOD: Each decorator has single responsibility
4545
class TimeoutDecorator { /* ONLY timeout protection */ };
4646
class ParallelDecorator { /* ONLY parallel execution */ };
47-
class AsyncDecorator { /* ONLY async capabilities */ };
47+
4848
class OutputDecorator { /* ONLY output handling */ };
4949
class SignalDecorator { /* ONLY signal processing */ };
5050
```
@@ -57,7 +57,6 @@ Facilities combine **without dependencies**:
5757
auto integrator = make_builder(base)
5858
.with_timeout() // Independent
5959
.with_parallel() // Independent
60-
.with_async() // Independent
6160
.with_signals() // Independent
6261
.with_output() // Independent
6362
.build();
@@ -79,7 +78,6 @@ public:
7978
#### 2. Independent Facilities
8079
- `TimeoutDecorator`: Timeout protection only
8180
- `ParallelDecorator`: Batch processing and Monte Carlo only
82-
- `AsyncDecorator`: Async execution only
8381
- `OutputDecorator`: Online/offline/hybrid output only
8482
- `SignalDecorator`: Signal processing only
8583
@@ -89,7 +87,6 @@ class IntegratorBuilder {
8987
public:
9088
IntegratorBuilder& with_timeout(TimeoutConfig = {});
9189
IntegratorBuilder& with_parallel(ParallelConfig = {});
92-
IntegratorBuilder& with_async(AsyncConfig = {});
9390
IntegratorBuilder& with_output(OutputConfig = {});
9491
IntegratorBuilder& with_signals(SignalConfig = {});
9592
std::unique_ptr<AbstractIntegrator<S, T>> build();
@@ -107,19 +104,19 @@ public:
107104
```cpp
108105
// Any combination works
109106
auto research = make_builder(base).with_timeout().with_parallel().build();
110-
auto realtime = make_builder(base).with_async().with_signals().build();
107+
auto realtime = make_builder(base).with_timeout().with_signals().build();
111108
auto server = make_builder(base).with_timeout().with_output().build();
112109
auto ultimate = make_builder(base).with_timeout().with_parallel()
113-
.with_async().with_signals()
110+
.with_signals()
114111
.with_output().build();
115112
```
116113

117114
### 3. Order Independence
118115
```cpp
119116
// These are identical:
120-
.with_timeout().with_async().with_output()
121-
.with_output().with_timeout().with_async()
122-
.with_async().with_output().with_timeout()
117+
.with_timeout().with_parallel().with_output()
118+
.with_output().with_timeout().with_parallel()
119+
.with_parallel().with_output().with_timeout()
123120
```
124121

125122
### 4. Unlimited Extensibility
@@ -149,7 +146,6 @@ auto research_integrator = make_builder(base_integrator)
149146
```cpp
150147
auto control_integrator = make_builder(base_integrator)
151148
.with_timeout(TimeoutConfig{.timeout_duration = std::chrono::milliseconds{10}})
152-
.with_async()
153149
.with_signals()
154150
.build();
155151
```
@@ -172,7 +168,7 @@ auto interactive_integrator = make_builder(base_integrator)
172168
return !user_cancelled();
173169
}
174170
})
175-
.with_async().with_signals().with_output()
171+
.with_signals().with_output()
176172
.build();
177173
```
178174
@@ -264,7 +260,6 @@ auto integrator = make_builder(base).with_timeout().build();
264260
auto integrator = make_builder(base)
265261
.with_timeout(TimeoutConfig{...})
266262
.with_parallel(ParallelConfig{...})
267-
.with_async(AsyncConfig{...})
268263
.with_signals(SignalConfig{...})
269264
.with_output(OutputConfig{...}, custom_handler)
270265
.build();

CI_DEBUG_SUMMARY.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,12 @@ The CI workflows are failing due to template parameter issues in the composable
1616
- **Fix**: Removed the `T` template parameter and updated all method signatures
1717
- **Status**: ✅ COMPLETED
1818

19-
### 3. AsyncDecorator
20-
- **File**: `include/core/composable/async_decorator.hpp`
21-
- **Fix**: Removed the `T` template parameter and updated all method signatures
22-
- **Status**: ✅ COMPLETED
23-
24-
### 4. OutputDecorator
19+
### 3. OutputDecorator
2520
- **File**: `include/core/composable/output_decorator.hpp`
2621
- **Fix**: Removed the `T` template parameter and updated all method signatures
2722
- **Status**: ✅ COMPLETED
2823

29-
### 5. SignalDecorator
24+
### 4. SignalDecorator
3025
- **File**: `include/core/composable/signal_decorator.hpp`
3126
- **Fix**: Removed the `T` template parameter and updated all method signatures, including the SignalInfo struct
3227
- **Status**: ✅ COMPLETED

COMPOSABLE_ARCHITECTURE.md

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ Instead, we use independent decorators that can be composed:
4545
auto integrator = make_builder(base_integrator)
4646
.with_timeout()
4747
.with_parallel()
48-
.with_async()
4948
.with_signals()
5049
.with_output()
5150
.build();
@@ -89,15 +88,6 @@ class ParallelDecorator : public IntegratorDecorator<S, T> {
8988
};
9089
```
9190
92-
#### Async Facility
93-
```cpp
94-
class AsyncDecorator : public IntegratorDecorator<S, T> {
95-
// ONLY handles async execution
96-
std::future<void> integrate_async(state& s, T dt, T end);
97-
std::future<void> step_async(state& s, T dt);
98-
};
99-
```
100-
10191
#### Output Facility
10292
```cpp
10393
class OutputDecorator : public IntegratorDecorator<S, T> {
@@ -124,7 +114,6 @@ class IntegratorBuilder {
124114
public:
125115
IntegratorBuilder& with_timeout(TimeoutConfig config = {});
126116
IntegratorBuilder& with_parallel(ParallelConfig config = {});
127-
IntegratorBuilder& with_async(AsyncConfig config = {});
128117
IntegratorBuilder& with_output(OutputConfig config = {});
129118
IntegratorBuilder& with_signals(SignalConfig config = {});
130119
@@ -142,9 +131,9 @@ auto timeout_integrator = make_builder(base_integrator)
142131
.with_timeout(TimeoutConfig{.timeout_duration = std::chrono::seconds{30}})
143132
.build();
144133

145-
// Async + signals
134+
// Timeout + signals
146135
auto realtime_integrator = make_builder(base_integrator)
147-
.with_async()
136+
.with_timeout()
148137
.with_signals()
149138
.build();
150139
```
@@ -159,7 +148,6 @@ auto ultimate_integrator = make_builder(base_integrator)
159148
.enable_progress_callback = true
160149
})
161150
.with_parallel(ParallelConfig{.max_threads = 8})
162-
.with_async(AsyncConfig{.thread_pool_size = 4})
163151
.with_signals(SignalConfig{.enable_real_time_processing = true})
164152
.with_output(OutputConfig{
165153
.mode = OutputMode::HYBRID,
@@ -177,13 +165,13 @@ The decorator pattern ensures composition order doesn't matter:
177165
```cpp
178166
// These are equivalent:
179167
auto integrator1 = make_builder(base)
180-
.with_timeout().with_async().with_output().build();
168+
.with_timeout().with_parallel().with_output().build();
181169

182170
auto integrator2 = make_builder(base)
183-
.with_output().with_timeout().with_async().build();
171+
.with_output().with_timeout().with_parallel().build();
184172

185173
auto integrator3 = make_builder(base)
186-
.with_async().with_output().with_timeout().build();
174+
.with_parallel().with_output().with_timeout().build();
187175
```
188176

189177
## Benefits
@@ -247,7 +235,6 @@ auto research_integrator = make_builder(base)
247235
```cpp
248236
auto control_integrator = make_builder(base)
249237
.with_timeout(TimeoutConfig{.timeout_duration = std::chrono::milliseconds{10}})
250-
.with_async()
251238
.with_signals()
252239
.build();
253240
```
@@ -273,7 +260,6 @@ auto interactive_integrator = make_builder(base)
273260
return !user_cancelled();
274261
}
275262
})
276-
.with_async()
277263
.with_signals()
278264
.with_output()
279265
.build();

IMPROVEMENTS_SUMMARY.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class ParallelTimeoutAsyncSignalIntegrator { ... };
2626
auto integrator = make_builder(base_integrator)
2727
.with_timeout() // Independent facility
2828
.with_parallel() // Independent facility
29-
.with_async() // Independent facility
3029
.with_signals() // Independent facility
3130
.with_output() // Independent facility
3231
.build(); // N classes for N facilities
@@ -43,7 +42,6 @@ include/core/composable/
4342
├── integrator_decorator.hpp # Base decorator pattern
4443
├── timeout_decorator.hpp # Timeout protection only
4544
├── parallel_decorator.hpp # Parallel execution only
46-
├── async_decorator.hpp # Async execution only
4745
├── output_decorator.hpp # Output handling only
4846
├── signal_decorator.hpp # Signal processing only
4947
└── integrator_builder.hpp # Composition builder
@@ -66,19 +64,13 @@ include/core/composable/
6664
- **Hardware Detection**: Automatic thread count detection
6765
- **Graceful Fallback**: Falls back to sequential on errors
6866
69-
### 3. AsyncDecorator Capabilities
70-
- **Operation Tracking**: Active operation counting and monitoring
71-
- **Cancellation Support**: Cooperative cancellation mechanism
72-
- **Progress Monitoring**: Optional progress monitoring with callbacks
73-
- **Resource Management**: RAII scope guards for proper cleanup
74-
75-
### 4. OutputDecorator Features
67+
### 3. OutputDecorator Features
7668
- **Multiple Modes**: Online, offline, and hybrid output
7769
- **File Output**: Optional file output with compression support
7870
- **Statistics**: Detailed performance monitoring and statistics
7971
- **Buffer Management**: Configurable buffering with overflow handling
8072
81-
### 5. SignalDecorator Enhancements
73+
### 4. SignalDecorator Enhancements
8274
- **Multiple Processing Modes**: Synchronous, asynchronous, and batch
8375
- **Priority System**: Signal priority handling with queues
8476
- **Thread Safety**: Mutex protection for concurrent signal access
@@ -150,7 +142,6 @@ auto research_integrator = make_builder(base_integrator)
150142
```cpp
151143
auto control_integrator = make_builder(base_integrator)
152144
.with_timeout(TimeoutConfig{.timeout_duration = std::chrono::milliseconds{10}})
153-
.with_async()
154145
.with_signals()
155146
.build();
156147
```
@@ -173,7 +164,7 @@ auto interactive_integrator = make_builder(base_integrator)
173164
return !user_cancelled(); // Allow cancellation
174165
}
175166
})
176-
.with_async().with_signals().with_output()
167+
.with_signals().with_output()
177168
.build();
178169
```
179170

@@ -225,7 +216,6 @@ auto ultimate_integrator = make_builder(base)
225216
.with_gpu() // New facility
226217
.with_network() // New facility
227218
.with_compression() // New facility
228-
.with_async()
229219
.with_signals()
230220
.with_output()
231221
.build();

docs/ASIO_INTEGRATION_GUIDE.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
- **可视化**:生成图表或动画
1313
- **并行计算**:启动多个相关的 ODE 计算
1414

15-
传统的做法是创建自定义的异步组件(如 `AsyncDecorator`,但这会导致:
15+
传统的做法是创建自定义的异步组件,但这会导致:
1616

1717
1. **重复发明轮子**:重新实现队列、线程池、协程等基础设施
1818
2. **维护负担**:需要处理复杂的异步编程细节
@@ -219,17 +219,6 @@ asio::thread_pool pool(4);
219219
220220
## 与现有组件的对比
221221
222-
### AsyncDecorator vs AsioIntegrationManager
223-
224-
| 特性 | AsyncDecorator | AsioIntegrationManager |
225-
|------|----------------|------------------------|
226-
| 线程管理 | 自定义线程池 | 使用 asio 线程池 |
227-
| 任务调度 | 自定义队列 | asio 事件循环 |
228-
| 协程支持 | 无 | 完整支持 |
229-
| 错误处理 | 基本 | 完整 |
230-
| 资源管理 | 手动 | 自动 |
231-
| 学习成本 | 高 | 低(标准 asio) |
232-
233222
### 推荐使用场景
234223
235224
**使用 AsioIntegrationManager 当:**
@@ -238,10 +227,10 @@ asio::thread_pool pool(4);
238227
- 需要与现有 asio 代码集成
239228
- 希望减少代码维护负担
240229
241-
**使用 AsyncDecorator 当:**
242-
- 需要积分器内部的异步化
243-
- 对 asio 有特殊限制
244-
- 需要更细粒度的控制
230+
**直接使用标准库 std::async 当:**
231+
- 只需要简单的异步执行
232+
- 不需要复杂的任务编排
233+
- 希望最小化依赖
245234
246235
## 最佳实践
247236

0 commit comments

Comments
 (0)