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

من موسوعة حسوب
< Ruby‏ | Thread
اذهب إلى التنقل اذهب إلى البحث
(أنشأ الصفحة ب'<noinclude>{{DISPLAYTITLE: التابع <code>report_on_exception=‎</code> الخاص بالصنف <code>Thread</code> في روبي}}</noinclude> تصنيف: Rub...')
 
سطر 3: سطر 3:
 
[[تصنيف: Ruby Method]]
 
[[تصنيف: Ruby Method]]
 
[[تصنيف: Ruby Thread]]
 
[[تصنيف: Ruby Thread]]
يُعيد التابع <code>report_on_exception=</code> الحالة الجديدة. عند إعطائه القيمة <code>true</code>، سترث كل [[Ruby/Thread|المهمة الفرعية]] التي تم إنشاؤها بعد ذلك الشرط (condition) وتبعث رسالة على المجرى $ stderr إذا أدى استثناء ما إلى إنهاء [[Ruby/Thread|مهمة فرعية]]:
+
يُعيد التعبير<code>report_on_exception =</code> الحالة الجديدة. عند إعطائه القيمة <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>.
هذا سوف ينتج:
 
 
 
<syntaxhighlight lang="ruby">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‎</syntaxhighlight>
 
 
 
انظر أيضا صفحة <code>[[Ruby/Thread/report_on_exception|::report_on_exception]]</code>.
 
 
 
يوجد أيضًا تابع نسخة (instance level method) لتعيين هذا الخيار ل[[Ruby/Thread|مهمة فرعية]] معينة، راجع <code>[[Ruby/Thread/report_on_exception-3D|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>report_on_exception=‎</code>:
 
مثال على استخدام التابع <code>report_on_exception=‎</code>:
سطر 29: سطر 21:
 
end
 
end
 
sleep(1)
 
sleep(1)
puts "In the main thread"‎</syntaxhighlight>
+
puts "In the main thread"‎</syntaxhighlight>هذا سوف ينتج:<syntaxhighlight lang="ruby">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‎</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>: يعيد التابع <code>report_on_exception</code> الحالة "report on exception".
* التابع <code>[[Ruby/Thread/run|run]]</code>: يوقظ التابع <code>run</code> [[Ruby/Thread|المهمة الفرعية]] <code>thr</code>، مما يجعلها متاحة للجدولة.
 
 
==مصادر==
 
==مصادر==
 
*[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‎ في توثيق روبي الرسمي.]

مراجعة 23:30، 5 نوفمبر 2018

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

انظر أيضا صفحة report_on_exception.

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

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

report_on_exception= boolean true or false

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

يُعيد التعبيرreport_on_exception =‎ قيمة منطقية تمثل الحالة الجديدة.

أمثلة

مثال على استخدام التابع 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 الحالة "report on exception".

مصادر