目录标题
- 1. Executor 在 AUTOSAR AP 中到底扮演什么角色?
- 1.1 从 “线程” 到 “执行上下文”:Core 的抽象视角
- 1.2 与 OS / Execution Management 的边界:谁管什么?
- 1.3 与 Future / Result / ErrorCode 的协同关系
- 2. 规范里的 Executor:需求与设计细节拆解
- 2.1 API 形态:一个轻量句柄,而非具体线程池
- 2.1.1 类级描述总结
- 2.1.2 special member functions 的要求
- 2.2 execute / oneway_execute 的精确语义
- 2.2.1 execute:有结果的异步调用
- 2.2.2 oneway_execute:fire-and-forget 调用
- 2.2.3 execute vs oneway_execute 对比表
- 2.3 与 Future continuation 的契约:then(F, ExecutorT)
- 3. 从规范到工程:Executor 的可实现方案
- 3.1 实现思想:值语义句柄 + 多态实现
- 3.2 典型 Executor 实现模式
- 3.2.1 线程池执行器(Thread-Pool Executor)
- 3.2.2 串行执行器(Serial / Strand Executor)
- 3.2.3 Inline / Immediate Executor(调试/测试用)
- 3.2.4 SoC 域特定 Executor(R-core / A-core)
- 3.3 与 asio / RTOS / EM 的集成:适配器模式
- 3.4 错误与 Violation 策略:如何吃掉异常?
- 3.5 小结:Executor 的“规范价值”与“工程价值”
- 结语
1. Executor 在 AUTOSAR AP 中到底扮演什么角色?
1.1 从 “线程” 到 “执行上下文”:Core 的抽象视角
在 AUTOSAR Adaptive Platform Core 规范中,ara::core::Executor被定义为执行上下文(executing context)的接口——它的职责不是“再造一个线程库”,而是给上层组件提供一个稳定的异步执行入口:把一个 Callable 丢给 Executor,它会在一个保证线程安全的上下文中异步执行,并在需要的时候返回Future供后续组合。
规范对类本身的描述非常克制:在ara/core/executor.h中,只给出了一个简单的类定义和一句话说明——Executor 是一个执行上下文接口,execute(...)返回ara::core::Future,oneway_execute(...)则体现 fire-and-forget 语义,不会产生任何 Future 上下文。