يتيح التوفير غير المتزامن لنتيجة void أو خطأ لكائن Future مرتبط.
مُولَّد بالذكاء الاصطناعيغير مُراجَعالنموذج: gemini-3.8-flash-medium · الجهد: medium · درجة الحرارة: غير قابل للتحكم · الموجّه: 5c77833bef95المصدرأسئلة مفتوحة (1)
مترجم من الدليل الألمانيgemini-3.8-flash-low · 2026-10-13 · الأصل الألماني
يتيح التوفير غير المتزامن لنتيجة void أو خطأ لكائن Future مرتبط.
يُستخدم التخصيص ara::core::Promise< void, E > كنقطة نهاية مُنتجة غير متزامنة للإشارة إلى اكتمال عملية بدون قيمة إرجاع أو لنقل خطأ ([SWS_CORE_06341]). بعد إنشاء النسخة، يتم استرداد Future المرتبط للمستهلك عبر get_future() لمرة واحدة فقط ([SWS_CORE_06344]). يتم التوفير بشكل آمن من حيث خيوط التنفيذ (thread-safe) عبر set_value() أو SetError() أو SetResult()، مما يجعل الحالة المشتركة موسومة بأنها جاهزة. ونظرًا لأن الفئة تمتلك دلالات نقل بحتة، فإن التعيين المتعدد أو غياب الحالات المشتركة يؤدي إلى انتهاكات محددة.
السياق
تمثل الفئة ara::core::Promise< void, E > تخصيص قالب للعمليات غير المتزامنة بدون قيمة بيانات مفيدة (نوع الإرجاع void). وهي تشكل جانب المُنتج (Producer) لقناة اتصال وتزامن الحسابات أو العمليات غير المتزامنة مع جانب المستهلك (Consumer). ومن خلال حالة داخلية مشتركة (Shared State)، تتيح الإشارة إما إلى الإنجاز الناجح لعملية ما أو إلى حدوث خطأ من النوع E. ويتم توفير كائن المستقبل المقابل في صورة ara::core::Future< void, E > ([SWS_CORE_06344]). وفقًا لمتطلبات AUTOSAR Adaptive Platform، يتطلب التنفيذ أن يكون نوع الخطأ E متوافقًا مع ara::core::ErrorCode؛ يؤدي أي اختلاف إلى حدوث خطأ أثناء التحويل البرمجي (Compilation).
دورة الحياة
يتم إنشاء النسخة عبر المنشئ الافتراضي الخالي من المعاملات [SWS_CORE_06341]، والذي يُنشئ حالة مشتركة جديدة ويتصرف بصورة مماثلة لدالة C++ القياسية std::promise. تُنمذج الفئة ملكية حصرية وتُنفذ دلالات نقل صارمة: تم حذف كل من منشئ النسخ ([SWS_CORE_06350]) ومعامل إسناد النسخ ([SWS_CORE_06351]) (delete).
يمكن نقل حالة موجودة إلى نسخ أخرى عبر منشئ النقل ([SWS_CORE_06342]) أو معامل إسناد النقل ([SWS_CORE_06343]). وعند إسناد النقل، يتم التخلي عن Shared State المحتفظ بها حتى ذلك الحين وتُنقل الحالة كما هو الحال بواسطة Promise(std::move(other)).swap(*this) ([SWS_CORE_06343]). علاوة على ذلك، تتيح الدالة swap ([SWS_CORE_06352]) التبادل المباشر بين حالتين.
تؤدي انتهاكات الشروط المسبقة إلى حالات خطأ محددة (Violations):
IsoStdFutureErrcFutureAlreadyRetrievedViolation: يتم إطلاقه إذا تم استدعاء get_future() عدة مرات للحالة المشتركة نفسها ([SWS_CORE_06344]).
IsoStdFutureErrcNoStateViolation: تحدث عندما يتم استدعاء get_future() دون أن تمتلك Promise حالة مشتركة ([SWS_CORE_06344])، كأن يكون ذلك بعد عملية نقل ([SWS_CORE_06342]).
فيما يتعلق بأمان الاستثناءات، تُعد الطريقتان SetError وSetResult آمنتين مشروطاً من حيث الاستثناءات (conditionally exception safe): فهما تضمنان noexcept فقط إذا تم تصنيف النوع E على أنه قابل للإنشاء بالنقل دون إطلاق استثناء (nothrow-move-constructible) أو قابل للإنشاء بالنسخ دون إطلاق استثناء (nothrow-copy-constructible) ([SWS_CORE_06353]، [SWS_CORE_06354]، [SWS_CORE_06355]، [SWS_CORE_06356]).
يستند دليل الفئات هذا إلى مواصفة AUTOSAR Adaptive Platform R25-11 وقد تم إنشاؤه بصورة آلية.
Return an associated Future with the same shared state as *this The returned Future is set as soon as this Promise receives the result, value, or an error. This fuction must only be called once as it is not allowed to have multiple Futures per Promise.
IsoStdFutureEr- If the shared state already has a stored value or error. rcPromiseAl- readySatisfiedVio- lation PromiseNoShared- If *this has no shared state. StateToSetViola- tion
Parameter (in)
Parameter
Beschreibung
error
the error to store
Rückgabewert
Typ
Beschreibung
None
Request a governed re-review of this record. The record is not changed immediately.
IsoStdFutureEr- If the shared state already has a stored value or error. rcPromiseAl- readySatisfiedVio- lation PromiseNoShared- If *this has no shared state. StateToSetViola- tion
Parameter (in)
Parameter
Beschreibung
error
the error to store
Rückgabewert
Typ
Beschreibung
None
Request a governed re-review of this record. The record is not changed immediately.
IsoStdFutureEr- If the shared state already has a stored value or error. rcPromiseAl- readySatisfiedVio- lation PromiseNoShared- If *this has no shared state. StateToSetViola- tion
Parameter (in)
Parameter
Beschreibung
result
the result to store
Rückgabewert
Typ
Beschreibung
None
Request a governed re-review of this record. The record is not changed immediately.
IsoStdFutureEr- If the shared state already has a stored value or error. rcPromiseAl- readySatisfiedVio- lation PromiseNoShared- If *this has no shared state. StateToSetViola- tion
Parameter (in)
Parameter
Beschreibung
result
the result to store
Rückgabewert
Typ
Beschreibung
None
Request a governed re-review of this record. The record is not changed immediately.
Return an associated Future with the same shared state as *this The returned Future is set as soon as this Promise receives the result, value, or an error. This fuction must only be called once as it is not allowed to have multiple Futures per Promise.
IsoStdFutureErrc- If the function is called more than once on the same shared FutureAlreadyRe- state. trievedViolation IsoStdFutureErrc- If *this has no shared state. NoStateViolation
IsoStdFutureEr- If the shared state already has a stored value or error. rcPromiseAl- readySatisfiedVio- lation PromiseNoShared- If *this has no shared state. StateToSetViola- tion
Rückgabewert
Typ
Beschreibung
None
Request a governed re-review of this record. The record is not changed immediately.
gemini-3.8-flash-low· 2026-10-13 · الأصل الألماني