pdf文档 Combining Co-Routines and Functions into a Job System

1.23 MB 39 页 0 评论
语言 格式 评分
英语
.pdf
3
摘要
The document presents the Vienna Game Job System (VGJS), a job system that integrates coroutines and normal functions. VGJS supports various callable types, including lambdas, std::function, and std::bind. Coroutines can return results, and functions can interact with them, though with some complications. The system shows good efficiency for larger thread counts but introduces overhead when allocating coroutines. Performance metrics demonstrate efficiency rates for different thread counts and job sizes, highlighting the importance of balancing work and overhead.
AI总结
《Combining Co-Routines and Functions into a Job System》摘要: 本文档介绍了一种结合协程和普通函数的任务系统(Job System),称为Vienna Game Job System(VGJS),其目标是提高多线程环境下的效率和灵活性。以下是核心内容的总结: ### 1. 系统设计与功能 - **任务调度**:支持普通函数、Lambda、`std::function`、`std::bind`、函数指针、自定义`Function`类以及协程的调度。 - **协程支持**:协程可以通过`co_await`进行挂起和恢复,且可以返回结果。 - **线程管理**:任务系统支持多线程调度,任务可以通过标签(tag)进行分组和管理。 - **高效性**:通过合理调度和减少任务粒度过小带来的开销,系统在较大规模线程环境中表现出较高效率。 ### 2. 协程实现细节 - **协程调度**:协程可以通过`schedule()`或`continuation()`进行调度。 - **结果存储**:协程的返回值存储在共享指针中,以避免协程和调用函数之间的生命周期问题。 - **线程切换**:`awaitable_resume_on`结构支持任务在特定线索上执行,减少线程切换开销。 ### 3. 性能与优化 - **任务粒度**:任务应尽量避免过小,以减少调度和管理开销。 - **效率测试**:文档提供了不同线程数(12线程和24线程)下的效率数据,显示任务系统在较大规模任务时效率达到85%以上。 - **开销分析**:任务分配和协程切换会引入一定开销,但整体性能在较大规模任务下表现良好。 ### 4. 结论 VGJS通过结合协程和普通函数,提供了一种灵活且高效的任务调度系统,适用于多线程环境下的游戏开发。尽管协程调度带来一定开销,但其在任务管理和效率上表现出较强的优势。 总结以上内容,VGJS在任务调度、协程支持和多线程环境下的性能表现方面具有显著优势,是一种值得考虑的任务系统设计方案。
P1
P2
P3
P4
P5
P6
P7
P8
P9
P10
P11
P12
下载文档到本地,方便使用
- 可预览页数已用完,剩余 27 页请下载阅读 -
文档评分
请文明评论,理性发言.