DEENESPTFRRUARHIKOZHNL

类 ara::core::Executor

[SWS_CORE_00008] Upstream: RS_AP_00130

class Executor {...};

Provides an interface for a executing context, which asynchronously invokes Callable ([4] [func.wrap.func]) objects in a guaranteed thread-safe context. The execute(...) method in [SWS_CORE_00024] returns a ara::core::Future object to the caller for further result/error extraction or management of the asynchronous-context; the execute_oneway(...) method in [SWS_CORE_00025] imply fire-and-forget semantics and thus no asynchronous-context (ara::core::Future) is returned.

Literaturverzeichnis SWS Core: [4] ISO/IEC 14882:2014, Information technology – Programming languages – C++ – www.iso.org

Header-Datei#include "ara/core/executor.h"
Forwarding-Header#include "ara/core/core_fwd.h"
Scopenamespace ara::core

用户指南人工智能生成

允许异步、线程安全地执行可调用对象,并可选择通过 Future 返回结果。
AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: 690890643de1 来源 未决问题(2)
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

允许异步、线程安全地执行可调用对象,并可选择通过 Future 返回结果。

类 ara::core::Executor 提供了在保证线程安全的上下文中异步执行可调用对象的接口。任务既可以通过 execute [SWS_CORE_00024] 以结果导向的方式启动,并返回用于值或错误代码的 ara::core::Future;也可以通过 oneway_execute [SWS_CORE_00025] 在 Fire-and-Forget 模式下以与状态无关的方式传递。作为关键边界条件需要注意的是,execute 本身不是线程安全的,在同一实例上的并发调用必须在外部进行同步,而 Callable 在后台的执行则是线程安全的。

上下文

类 ara::core::Executor 为执行上下文提供接口,该上下文在有保证的线程安全环境中异步执行可调用单元(Callable)。它充当调用线程与异步后台处理之间的抽象层。对于任务传递,有两种机制可用:方法 execute [SWS_CORE_00024] 以结果导向的方式传递任务并返回 ara::core::Future 对象,可以通过该对象同步并查询后续的返回值或错误代码。对于纯通知或与状态无关的后台操作,该类提供了方法 oneway_execute [SWS_CORE_00025],该方法遵循 Fire-and-Forget 语义,不向调用方返回异步上下文。推测具体的后台实现封装了线程管理或任务队列,以协调并发处理。 问题 Q-068fe33f2900d6cf (未决)

生命周期

ara::core::Executor 的实例化和生命周期在异常安全性和线程安全性方面遵循差异化的规则:

  • 复制:复制构造函数 [SWS_CORE_00009] 以及复制赋值运算符 [SWS_CORE_00017] 被指定为线程安全,但未被归类为异常安全(not exception safe)。因此,如果无法分配所需资源,复制过程可能会失败。
  • 移动:移动构造函数 [SWS_CORE_00015] 和移动赋值运算符 [SWS_CORE_00018] 被声明为 noexcept,因而属于异常安全。然而,移动操作不是线程安全的(not thread-safe),因此移动期间的并发访问必须由调用方进行同步。
  • 销毁:析构函数 [SWS_CORE_00019] 为 noexcept 且为线程安全实现,从而可以安全终止实例的生命周期。

关于运行期间的并发性,呈现出一种根本性的划分:虽然 oneway_execute [SWS_CORE_00025] 是线程安全的,但 execute [SWS_CORE_00024] 被归类为非线程安全。execute 缺乏线程安全性可能是由于内部生成和管理所得 Future 的底层状态对象所致,因此必须对同一实例上 execute 的并发调用进行外部同步。 问题 Q-4425e6b07758230e (未决)

使用路径

ara::core::Executor 的使用分为两条主要路径,具体取决于是否需要返回值:

  1. 结果导向路径(execute):调用方将可调用对象 f 以及可选参数 p... 传递给 execute [SWS_CORE_00024]。该方法立即返回一个 ara::core::Future,其结果类型基于调用的推导返回类型。Callable 在有保证的上下文中异步执行。一旦处理完成,调用方就可以从 Future 中提取结果值或潜在的错误代码。
  2. 单向路径(oneway_execute):如果调用方既不需要反馈也不需要同步,则调用 oneway_execute [SWS_CORE_00025]。Callable 同样异步执行,但不存在返回值(void)。
使用 ara::core::Executor 的异步执行流程调用方ara::core::ExecutorAsynchroner Kontextara::core::Futureexecute(f, p...)Future erzeugen返回 ara::core::Futuref(p...) asynchron starten执行 Callable f(p...)设置结果或错误Ergebnis / Fehler abfragenErgebniswert / Fehlercode

时序图:通过 execute 进行异步任务处理以及通过 Future 查询结果。来源:[SWS_CORE_00024]

错误场景

调用方法 execute [SWS_CORE_00024] 和 oneway_execute [SWS_CORE_00025] 不抛出 C++ 异常;两者均被显式指定为 noexcept。同样,规范未针对 execute 的传递调用本身定义标准化错误代码 [SWS_CORE_00024]。

然而,如果在 Callable 的异步处理期间发生错误,则该错误将通过 execute 返回的 ara::core::Future 传播:在发生错误时,Future 封装错误代码;而在成功时,将提供带有函数结果的类型 ara::core::Result::value_type [SWS_CORE_00024]。对于 oneway_execute [SWS_CORE_00025],由于设计原因,无法向调用方返回错误;错误保留在异步上下文中。

本指南由 AI 整理,并完全基于 AUTOSAR Adaptive R25-11 规范。

成员图

构造函数和析构函数

2

运算符

1

类图

Hohle Dreieckspfeile = Vererbung (zeigt zur Basisklasse); Klicken öffnet die jeweilige Klassenseite.

G nara__core__Executor877 Executor + Executor() + operator=() + ~Executor() + execute() + oneway_execute()

详细视图

请在大纲中选择一个条目。

构造函数和析构函数

Executor 函数 2

Copy constructor

重载 Executor 2
Executor (const Executor &other); SWS_CORE_00009
Executor (Executor &&other) noexcept; SWS_CORE_00015
~Executor 函数

Destructor

~Executor () noexcept;

方法

execute 函数

Asynchronously invoke F with the provided arguments P....

template <class F, class... P> ara::core::Future< std::invoke_result_t< std::decay_t< F >, std::decay_t< P >... > > execute (F &&f, P &&... p) noexcept;

Asynchronously invoke F with the provided arguments P....

template <class F, class... P> void oneway_execute (F &&f, P &&... p) noexcept;

运算符

operator= 函数 2

Copy assignment operator

重载 = 2
Executor & operator= (const Executor &other); SWS_CORE_00017
Executor & operator= (Executor &&other) noexcept; SWS_CORE_00018

方法文档

函数 Executor [SWS_CORE_00009] Upstream: RS_AP_00130

Executor (const Executor &other);

Copy constructor

Header-Datei#include "ara/core/executor.h"
Scopeclass ara::core::Executor
Exception-Sicherheitnot exception safe
Thread-Sicherheitthread-safe

Parameter (in)

ParameterBeschreibung
otherOther ara::core::Executor to copy

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_CORE_00009
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_00009@rel:R25-11#1177de2b
Content hash
1177de2b
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_00009
Status: valid/unmigrated Version: rel:R25-11#60a2a566 Versionshistorie & Revisions (1 transition, 3 revision)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/SWS_CORE_00009@rel:R25-11#60a2a566
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#3391383e2026-09-30
  • R24-11rel:R24-11#6c85f96c2026-10-14
  • R25-11rel:R25-11#60a2a5662026-10-14 active
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill

函数 Executor [SWS_CORE_00015] Upstream: RS_AP_00130

Executor (Executor &&other) noexcept;

Move constructor

Header-Datei#include "ara/core/executor.h"
Scopeclass ara::core::Executor
Exception-Sicherheitexception safe
Thread-Sicherheitnot thread-safe

Parameter (in)

ParameterBeschreibung
otherOther ara::core::Executor to move

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_CORE_00015
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_00015@rel:R25-11#a687bc44
Content hash
a687bc44
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_00015
Status: valid/unmigrated Version: rel:R25-11#aa1a25ba Versionshistorie & Revisions (1 transition, 3 revision)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/SWS_CORE_00015@rel:R25-11#aa1a25ba
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#5a1547e72026-09-30
  • R24-11rel:R24-11#0606a2422026-10-14
  • R25-11rel:R25-11#aa1a25ba2026-10-14 active
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill

函数 execute [SWS_CORE_00024] Upstream: RS_AP_00130

template <class F, class... P> ara::core::Future< std::invoke_result_t< std::decay_t< F >, std::decay_t< P >... > > execute (F &&f, P &&... p) noexcept;

Asynchronously invoke F with the provided arguments P....

AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: 9d31d266cefd 来源 未决问题(1)
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

类 ara::core::Executor 的函数 execute 用于异步执行传入的函数对象 f 以及实参 p... ([SWS_CORE_00024])。作为返回值,它提供一个 ara::core::Future,在成功时封装调用的结果,或在失败时提供相应的错误码 ([SWS_CORE_00024])。函数本身使用说明符 noexcept 声明。

未为该函数调用指定标准化错误码 ([SWS_CORE_00024])。关于并发性,虽然 execute 被归类为 exception safe,但被明确视为 not thread-safe ([SWS_CORE_00024])。因此,对 ara::core::Executor 的同一实例的并发访问可能需要在用户层进行同步。 问题 Q-6b839826a7d9742f (未决)

与异步控制流的交互特别体现在通过 then 进行的链式调用中 ([SWS_CORE_00337], [SWS_CORE_06237])。在该处传递一个执行器上下文,后续延续函数将在该上下文中使用获得的 ara::core::Result 执行。

本文自动生成。所有专业内容均基于 AUTOSAR Adaptive R25-11 规范。

Header-Datei#include "ara/core/executor.h"
Scopeclass ara::core::Executor
Exception-Sicherheitexception safe
Thread-Sicherheitnot thread-safe

Template-Parameter

ParameterBeschreibung
Fa Callable type
Pargument list to the Callable

Parameter (in)

ParameterBeschreibung
fa Callable to be executed
pparameters to be supplied with the Callable

Rückgabewert

TypBeschreibung
ara::core::Future<std::invoke_result_t<std::decay_t< F >, std::decay_t< P >... > >• If successful: an ara::core::Future containing a ara:: core::Result::value_type containing the result of the callable F • If unsuccessful: an ara::core::Future containing an Error Code

Fehler

FehlercodeBeschreibung
This function does not specify any standardized errors.

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_CORE_00024
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_00024@rel:R25-11#cae4dcab
Content hash
cae4dcab
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_00024
Status: valid/unmigrated Version: rel:R25-11#6c85a6a9 Versionshistorie & Revisions (1 transition, 3 revision)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/SWS_CORE_00024@rel:R25-11#6c85a6a9
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#8144c3b12026-09-30
  • R24-11rel:R24-11#d465a8212026-10-14
  • R25-11rel:R25-11#6c85a6a92026-10-14 active
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill

函数 oneway_execute [SWS_CORE_00025] Upstream: RS_AP_00130

template <class F, class... P> void oneway_execute (F &&f, P &&...                p) noexcept;

Asynchronously invoke F with the provided arguments P....

AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: 1e96ad32e48d 来源 未决问题(1)
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

用法与语义

类 ara::core::Executor 的模板函数 oneway_execute 用于使用传入的参数 p... 异步执行可调用实体 f(Callable)[SWS_CORE_00025]。由于该函数不返回任何值(返回类型 void)且执行是异步的,因此调用会立即返回给调用方,而无需等待执行结束或结果 [SWS_CORE_00025]。

错误处理与异常安全性

该函数被声明为 noexcept 并被指定为异常安全(exception safe)[SWS_CORE_00025]。因此,传入的 Callable 内部可能发生的错误或异常推测必须由 Callable 内部自行捕获和处理,因为任何错误反馈或异常都无法传递到调用上下文。 问题 Q-c8d31cfa9c2e3ab9 (未决)

并发性与限制

根据规范,oneway_execute 被归类为线程安全(thread-safe)[SWS_CORE_00025]。因此,可以从不同线程在 ara::core::Executor 的同一实例上并发调用该函数。通过头文件 #include "ara/core/executor.h" 包含 [SWS_CORE_00025]。

本使用说明基于 AUTOSAR R25-11 自动创建。

Header-Datei#include "ara/core/executor.h"
Scopeclass ara::core::Executor
Exception-Sicherheitexception safe
Thread-Sicherheitthread-safe

Template-Parameter

ParameterBeschreibung
Fa Callable type
Pargument list to the Callable

Parameter (in)

ParameterBeschreibung
fa Callable to be executed
pparameters to be supplied with the Callable

Rückgabewert

TypBeschreibung
None

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_CORE_00025
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_00025@rel:R25-11#edd21d94
Content hash
edd21d94
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_00025
Status: valid/unmigrated Version: rel:R25-11#f89da2ea Versionshistorie & Revisions (1 transition, 3 revision)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/SWS_CORE_00025@rel:R25-11#f89da2ea
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#ebd0128b2026-09-30
  • R24-11rel:R24-11#fe75fa6e2026-10-14
  • R25-11rel:R25-11#f89da2ea2026-10-14 active
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill

函数 operator= [SWS_CORE_00017] Upstream: RS_AP_00130

Executor & operator= (const Executor &other);

Copy assignment operator

Header-Datei#include "ara/core/executor.h"
Scopeclass ara::core::Executor
Exception-Sicherheitnot exception safe
Thread-Sicherheitthread-safe

Parameter (in)

ParameterBeschreibung
otherOther ara::core::Executor to copy

Rückgabewert

TypBeschreibung
Executor &The copied object

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_CORE_00017
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_00017@rel:R25-11#083569c2
Content hash
083569c2
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_00017
Status: valid/unmigrated Version: rel:R25-11#6011a69d Versionshistorie & Revisions (1 transition, 3 revision)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/SWS_CORE_00017@rel:R25-11#6011a69d
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#c0dcae292026-09-30
  • R24-11rel:R24-11#137015232026-10-14
  • R25-11rel:R25-11#6011a69d2026-10-14 active
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill

函数 operator= [SWS_CORE_00018] Upstream: RS_AP_00130

Executor & operator= (Executor &&other) noexcept;

Move assignment operator

Header-Datei#include "ara/core/executor.h"
Scopeclass ara::core::Executor
Exception-Sicherheitexception safe
Thread-Sicherheitnot thread-safe

Parameter (in)

ParameterBeschreibung
otherOther ara::core::Executor to move

Rückgabewert

TypBeschreibung
Executor &The moved object

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_CORE_00018
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_00018@rel:R25-11#130f0aee
Content hash
130f0aee
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_00018
Status: valid/unmigrated Version: rel:R25-11#1ca71ff7 Versionshistorie & Revisions (1 transition, 3 revision)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/SWS_CORE_00018@rel:R25-11#1ca71ff7
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#57cffdd32026-09-30
  • R24-11rel:R24-11#15bce54f2026-10-14
  • R25-11rel:R25-11#1ca71ff72026-10-14 active
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill

函数 ~Executor [SWS_CORE_00019] Upstream: RS_AP_00130

~Executor () noexcept;

Destructor

Header-Datei#include "ara/core/executor.h"
Scopeclass ara::core::Executor
Exception-Sicherheitexception safe
Thread-Sicherheitthread-safe

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_CORE_00019
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_00019@rel:R25-11#31001119
Content hash
31001119
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_00019
Status: valid/unmigrated Version: rel:R25-11#336c443d Versionshistorie & Revisions (1 transition, 3 revision)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/SWS_CORE_00019@rel:R25-11#336c443d
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#96c96d482026-09-30
  • R24-11rel:R24-11#7a18cb1c2026-10-14
  • R25-11rel:R25-11#336c443d2026-10-14 active
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill