الفرق بين المراجعتين ل"Ruby/Thread/thread variables"

من موسوعة حسوب
< Ruby‏ | Thread
اذهب إلى التنقل اذهب إلى البحث
ط (مراجعة وتدقيق.)
 
سطر 1: سطر 1:
<noinclude>{{DISPLAYTITLE: التابع <code>thread_variables‎</code> الخاص بالصنف <code>Thread</code> في روبي}}</noinclude>
+
<noinclude>{{DISPLAYTITLE: التابع <code>Thread.thread_variables‎</code> في روبي}}</noinclude>
 
[[تصنيف: Ruby]]
 
[[تصنيف: Ruby]]
 
[[تصنيف: Ruby Method]]
 
[[تصنيف: Ruby Method]]
 
[[تصنيف: Ruby Thread]]
 
[[تصنيف: Ruby Thread]]
يُعيد التابع <code>thread_variables</code> [[Ruby/Array|مصفوفة]] من أسماء المتغيرات المحلية في [[Ruby/Thread|المهمة الفرعية]] (thread-local) (على شكل رموز).
+
يُعيد التابع <code>thread_variables</code> [[Ruby/Array|مصفوفة]] من أسماء المتغيرات المحلية في [[Ruby/Thread|المهمة الفرعية]] (thread-local) على شكل رموز.
  
لاحظ أن هذه المتغيرات ليست محلية [[Ruby/Fiber|الألياف]] (fiber local). يرجى الاطلاع على صفحتي <code>[[Ruby/Thread/index operator|[]]]</code> و <code>[[Ruby/Thread/thread_variable_get|thread_variable_get]]</code> لمزيد من التفاصيل.
+
لاحظ أن هذه المتغيرات ليست محلية [[Ruby/Fiber|الألياف]] (fiber local). يرجى الاطلاع على صفحة المعامل <code>[[Ruby/Thread/index operator|[]]]</code> والتابع <code>[[Ruby/Thread/thread_variable_get|thread_variable_get]]</code> لمزيد من التفاصيل.
 
==البنية العامة==
 
==البنية العامة==
 
<syntaxhighlight lang="ruby">thread_variables→ array‎</syntaxhighlight>
 
<syntaxhighlight lang="ruby">thread_variables→ array‎</syntaxhighlight>
==القيمة المُعادة==
+
==القيمة المعادة==
يُعيد التابع <code>thread_variables</code> [[Ruby/Array|مصفوفة]] من أسماء المتغيرات المحلية في [[Ruby/Thread|المهمة الفرعية]] (thread-local) (على شكل رموز).
+
تعاد [[Ruby/Array|مصفوفة]] من أسماء المتغيرات المحلية في [[Ruby/Thread|المهمة الفرعية]] (thread-local) على شكل رموز.
  
 
==أمثلة==
 
==أمثلة==
سطر 19: سطر 19:
 
thr.join              #=> #<Thread:0x401b3f10 dead>
 
thr.join              #=> #<Thread:0x401b3f10 dead>
 
thr.thread_variables  #=> [:dog, :cat]‎</syntaxhighlight>
 
thr.thread_variables  #=> [:dog, :cat]‎</syntaxhighlight>
==انظر أيضا==
+
==انظر أيضًا==
* التابع <code>[[Ruby/Thread/thread_variable_set|thread_variable_set]]</code>: يعين التابع <code>thread_variable_set</code> المتغيرا المحلي في [[Ruby/Thread|المهمة الفرعية]] (thread local).
+
* التابع <code>[[Ruby/Thread/thread variable set|thread_variable_set]]</code>: يعين متغير محلي محدَّد في [[Ruby/Thread|المهمة الفرعية]] (thread local) إلى قيمة معيَّنة.
* التابع <code>[[Ruby/Thread/thread variable get|thread_variable_get]]</code>: يُعيد التابع <code>thread_variable_get</code> قيمة المتغير المحلي في المهمة الفرعية (thread local variable) الذي تم تعيينه.
+
* التابع <code>[[Ruby/Thread/thread variable get|thread_variable_get]]</code>: يُعيد قيمة المتغير المحلي في المهمة الفرعية (thread local variable) الذي تم تعيينه.
 
==مصادر==
 
==مصادر==
*[http://ruby-doc.org/core-2.5.1/Thread.html#method-i-thread_variables قسم التابع thread_variables‎ في الصنف Thread‎ في توثيق روبي الرسمي.]
+
*[http://ruby-doc.org/core-2.5.1/Thread.html#method-i-thread_variables قسم التابع thread_variables‎ في الصنف Thread‎ في توثيق روبي الرسمي.]

المراجعة الحالية بتاريخ 08:38، 6 ديسمبر 2018

يُعيد التابع thread_variables مصفوفة من أسماء المتغيرات المحلية في المهمة الفرعية (thread-local) على شكل رموز.

لاحظ أن هذه المتغيرات ليست محلية الألياف (fiber local). يرجى الاطلاع على صفحة المعامل [] والتابع thread_variable_get لمزيد من التفاصيل.

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

thread_variables array

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

تعاد مصفوفة من أسماء المتغيرات المحلية في المهمة الفرعية (thread-local) على شكل رموز.

أمثلة

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

thr = Thread.new do
  Thread.current.thread_variable_set(:cat, 'meow')
  Thread.current.thread_variable_set("dog", 'woof')
end
thr.join               #=> #<Thread:0x401b3f10 dead>
thr.thread_variables   #=> [:dog, :cat]‎

انظر أيضًا

  • التابع thread_variable_set: يعين متغير محلي محدَّد في المهمة الفرعية (thread local) إلى قيمة معيَّنة.
  • التابع thread_variable_get: يُعيد قيمة المتغير المحلي في المهمة الفرعية (thread local variable) الذي تم تعيينه.

مصادر