الفرق بين المراجعتين ل"Ruby/Thread/report on exception-3D"

من موسوعة حسوب
< Ruby‏ | Thread
اذهب إلى التنقل اذهب إلى البحث
 
(مراجعة متوسطة واحدة بواسطة نفس المستخدم غير معروضة)
سطر 1: سطر 1:
<noinclude>{{DISPLAYTITLE: التابع <code>report_on_exception=‎</code> الخاص بالصنف <code>Thread</code> في روبي}}</noinclude>
+
<noinclude>{{DISPLAYTITLE: التابع <code>Thread.report_on_exception=‎</code> في روبي}}</noinclude>
 
[[تصنيف: Ruby]]
 
[[تصنيف: Ruby]]
 
[[تصنيف: Ruby Method]]
 
[[تصنيف: Ruby Method]]
 
[[تصنيف: Ruby Thread]]
 
[[تصنيف: Ruby Thread]]
يُعيد التعبير<code>report_on_exception =</code> الحالة الجديدة. عند إعطائه القيمة <code>true</code>، سترث كل [[Ruby/Thread|المهام الفرعية]] التي تم إنشاؤها لاحقا الشرط (condition) وتبعث رسالة على المجرى ‎<code>$stderr</code> إذا أدى استثناء ما إلى إنهاء [[Ruby/Thread|مهمة فرعية]].
+
يضبط التابع <code>report_on_exception</code> عند استدعائه بالشكل <code>report_on_exception= boolean‎</code> حالة "التبليغ عند الاستثناء" (report on exception). عندما تكون القيمة المنطقية هي <code>true</code>، سترث كل [[Ruby/Thread|المهام الفرعية]] التي تم إنشاؤها لاحقا الشرط (condition) وتبعث رسالة إلى المجرى ‎<code>$stderr</code> إذا أدى استثناء ما إلى إنهاء [[Ruby/Thread|مهمة فرعية]].
  
انظر أيضا صفحة <code>[[Ruby/Thread/report_on_exception|report_on_exception]]</code>.
+
يوجد أيضًا تابع نسخة (instance level method) لتعيين هذا الخيار ل[[Ruby/Thread|مهمة فرعية]] معينة؛ راجع <code>[[Ruby/Thread/report on exception-3D-i|report_on_exception=‎]]</code>.
 
 
يوجد أيضًا تابع نسخة (instance level method) لتعيين هذا الخيار ل[[Ruby/Thread|مهمة فرعية]] معينة، راجع <code>[[Ruby/Thread/report on exception-3D-i|report_on_exception=‎]]</code>.
 
 
==البنية العامة==
 
==البنية العامة==
 
<syntaxhighlight lang="ruby">report_on_exception= boolean→ true or false‎</syntaxhighlight>
 
<syntaxhighlight lang="ruby">report_on_exception= boolean→ true or false‎</syntaxhighlight>
==القيمة المُعادة==
+
==القيمة المعادة==
يُعيد التعبير<code>report_on_exception =‎</code> قيمة منطقية تمثل الحالة الجديدة.
+
تعاد القيمة المنطقية <code>boolean</code> التي تمثل الحالة الجديدة لحالة "التبليغ عند الاستثناء".
  
 
==أمثلة==
 
==أمثلة==
سطر 21: سطر 19:
 
end
 
end
 
sleep(1)
 
sleep(1)
puts "In the main thread"‎</syntaxhighlight>هذا سوف ينتج:<syntaxhighlight lang="ruby">In new thread
+
puts "In the main thread"‎</syntaxhighlight>هذا سوف ينتج:<syntaxhighlight lang="text">In new thread
 
#<Thread:...prog.rb:2> terminated with exception (report_on_exception is true):
 
#<Thread:...prog.rb:2> terminated with exception (report_on_exception is true):
 
Traceback (most recent call last):
 
Traceback (most recent call last):
 
prog.rb:4:in `block in <main>': Exception from thread (RuntimeError)
 
prog.rb:4:in `block in <main>': Exception from thread (RuntimeError)
 
In the main thread‎</syntaxhighlight>
 
In the main thread‎</syntaxhighlight>
==انظر أيضا==
+
==انظر أيضًا==
* التابع <code>[[Ruby/Thread/report_on_exception|report_on_exception]]</code>: يعيد التابع <code>report_on_exception</code> الحالة "report on exception".
+
* التابع <code>[[Ruby/Thread/report_on_exception|report_on_exception]]</code>: يعيد حالة "التبليغ عند الاستثناء" (report on exception).
 
==مصادر==
 
==مصادر==
*[http://ruby-doc.org/core-2.5.1/Thread.html#method-i-report_on_exception-3D قسم التابع report_on_exception=‎ في الصنف Thread‎ في توثيق روبي الرسمي.]
+
*[http://ruby-doc.org/core-2.5.1/Thread.html#method-i-report_on_exception-3D قسم التابع report_on_exception=‎ في الصنف Thread‎ في توثيق روبي الرسمي.]

المراجعة الحالية بتاريخ 12:49، 5 ديسمبر 2018

يضبط التابع report_on_exception عند استدعائه بالشكل report_on_exception= boolean‎ حالة "التبليغ عند الاستثناء" (report on exception). عندما تكون القيمة المنطقية هي true، سترث كل المهام الفرعية التي تم إنشاؤها لاحقا الشرط (condition) وتبعث رسالة إلى المجرى ‎$stderr إذا أدى استثناء ما إلى إنهاء مهمة فرعية.

يوجد أيضًا تابع نسخة (instance level method) لتعيين هذا الخيار لمهمة فرعية معينة؛ راجع report_on_exception=‎.

البنية العامة

report_on_exception= boolean true or false

القيمة المعادة

تعاد القيمة المنطقية boolean التي تمثل الحالة الجديدة لحالة "التبليغ عند الاستثناء".

أمثلة

مثال على استخدام التابع report_on_exception=‎:

Thread.report_on_exception = true
t1 = Thread.new do
  puts  "In new thread"
  raise "Exception from thread"
end
sleep(1)
puts "In the main thread"

هذا سوف ينتج:

In new thread
#<Thread:...prog.rb:2> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
prog.rb:4:in `block in <main>': Exception from thread (RuntimeError)
In the main thread‎

انظر أيضًا

  • التابع report_on_exception: يعيد حالة "التبليغ عند الاستثناء" (report on exception).

مصادر