Commit 964eca0
committed
add coroutine priority support to TrueAsync API
Implements priority-based coroutine scheduling where higher priority values
result in coroutines being queued at the front of the execution queue.
## Changes
### Circular Buffer Enhancement
- Add `circular_buffer_push_front()` function to insert elements at buffer head
- Fallback to normal push when front insertion is not possible (buffer full)
### API Extension
- Update `zend_async_spawn_t` typedef to include `int32_t priority` parameter
- Add new macros:
- `ZEND_ASYNC_SPAWN_WITH_PRIORITY(priority)`
- `ZEND_ASYNC_SPAWN_WITH_SCOPE_EX(scope, priority)`
- Maintain backward compatibility by updating existing macros to pass priority=0
### Priority Logic
- Priority > 0: coroutine queued at front (high priority)
- Priority ≤ 0: coroutine queued at back (normal/low priority)
- Preserves existing behavior for all current code
### Files Modified
- `ext/async/internal/circular_buffer.{h,c}` - Buffer front insertion
- `Zend/zend_async_API.{h,c}` - API definitions and stub functions
- `ext/async/async_API.c` - Priority-aware spawn implementation
## Backward Compatibility
All existing spawn macros unchanged in behavior, new priority parameter
defaults to 0 for normal scheduling order.1 parent a234299 commit 964eca0
2 files changed
+7
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | | - | |
| 187 | + | |
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| |||
1231 | 1231 | | |
1232 | 1232 | | |
1233 | 1233 | | |
1234 | | - | |
1235 | | - | |
1236 | | - | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
1237 | 1239 | | |
1238 | 1240 | | |
1239 | 1241 | | |
| |||
0 commit comments