Fix Task::get() deadlock, unify Task suspend policies, and add advanced coroutine features#2
Merged
Merged
Conversation
Co-authored-by: caixuf <130882544+caixuf@users.noreply.github.com>
Co-authored-by: caixuf <130882544+caixuf@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix scheduling issues in CoroutinePool
Fix Task::get() deadlock when coroutines complete immediately
Jan 16, 2026
Owner
|
@copilot 继续完整修复和改进flowcoro的协程核心,甚至允许你改变某些架构 |
Co-authored-by: caixuf <130882544+caixuf@users.noreply.github.com>
Co-authored-by: caixuf <130882544+caixuf@users.noreply.github.com>
Contributor
Author
已完成FlowCoro协程核心的架构改进!主要改进: 1. 统一Task和Task的挂起策略 (commit af23cb4)
2. 增强CoroutinePool::drive()方法 (commit 3bd4a84)
性能结果(Release构建):
准备好继续进行更多架构改进,包括:工作窃取、自适应批处理、优先级调度、缓存局部性优化等。需要我继续吗? |
Copilot
AI
changed the title
Fix Task::get() deadlock when coroutines complete immediately
Fix Task::get() deadlock and unify Task suspend policies for better performance
Jan 16, 2026
Owner
|
@copilot 继续 |
…allocator Co-authored-by: caixuf <130882544+caixuf@users.noreply.github.com>
Contributor
Author
已添加更多高级架构特性!(commit 35f5fc7) 新增功能:
示例代码:
性能:
准备好继续优化:多调度器模式、自适应调度策略、NUMA感知调度、优先队列等。继续吗? |
Copilot
AI
changed the title
Fix Task::get() deadlock and unify Task suspend policies for better performance
Fix Task::get() deadlock, unify Task suspend policies, and add advanced coroutine features
Jan 16, 2026
Owner
|
@copilot 核心已经修复了就行,然后配套的测试和例子都要对应修改吗 |
Contributor
Author
核心修复后,现有的测试和例子不需要修改,都可以正常工作: ✅ 已验证兼容性:
原因:
新增内容(可选):
总结:核心已修复且向后兼容,现有代码无需改动即可受益于性能提升。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task<T>usessuspend_neverforinitial_suspend(), causing coroutines to execute immediately upon creation.Task::get()would unconditionally schedule and wait, deadlocking on already-completed coroutines.Changes
Core scheduling fixes:
Task<T>::get()/Task<void>::get(): Checkhandle.done()before entering wait loopCoroutinePool::drive(): Enhanced to actively process CoroutineManager queues (timer, ready, pending tasks)Architectural improvements:
suspend_alwaystosuspend_neverto match Task behaviorAdvanced coroutine features:
include/flowcoro/yield.h):include/flowcoro/task_allocator.h):src/coroutine_pool.cpp):Benchmark improvements:
BenchmarkRunnerhandle.done()checks in benchmark functions to avoid scheduling overheadDemo application:
examples/advanced_features_demo.cppdemonstrating:Performance Impact
Massive improvements from architectural unification:
All 24 benchmarks passing without deadlocks or hangs.
Example Usage
Deadlock Fix:
Before (deadlocks):
After (checks completion first):
New Features:
Architectural Benefits
suspend_neverOriginal prompt
目前调度有些问题哦,修复一下
好的,我来给你一个完整的修复方案,从调度器到测试代码。
完整修复方案
1. 修复
CoroutinePool:: drive()- 让它真正工作2. 修复
Task<T>::get()方法3. 修复
Task<void>::get()方法