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

من موسوعة حسوب
< Ruby‏ | Thread
اذهب إلى التنقل اذهب إلى البحث
(أنشأ الصفحة ب'<noinclude>{{DISPLAYTITLE: التابع <code>thread_variables‎</code> الخاص بالصنف <code>Thread</code> في روبي}}</noinclude> تصنيف: Ruby...')
 
سطر 5: سطر 5:
 
يُعيد التابع <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/5B-5D|#[]]]</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) (على شكل رموز).
 +
 
==أمثلة==
 
==أمثلة==
 
مثال على استخدام التابع <code>thread_variables‎</code>:
 
مثال على استخدام التابع <code>thread_variables‎</code>:
سطر 20: سطر 20:
 
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>key</code> ويعطيه القيمة <code>[[Ruby/Thread/value|value]]</code> (انظر فقرة البنية العامة).  لاحظ أن هذه المتغيرات محلية في [[Ruby/Thread|المهمة الفرعية]]، وليس في [[Ruby/Fiber|الألياف]].  يرجى الاطلاع على <code>[[Ruby/Thread/thread_variable_get|#thread_variable_get]]</code> و <code>[[Ruby/Thread/5B-5D|#[]]]</code> لمزيد من المعلومات.
+
* التابع <code>[[Ruby/Thread/thread_variable_set|thread_variable_set]]</code>: يعين التابع <code>thread_variable_set</code> المتغيرا المحلي في [[Ruby/Thread|المهمة الفرعية]] (thread local).
* التابع <code>[[Ruby/Thread/to_s|to_s]]</code>: يضع التابع <code>to_s</code> الاسم و رقم التعريف وحالة [[Ruby/Thread|المهمة الفرعية]] <code>thr</code> في [[Ruby/String|سلسلة نصية]].
+
* التابع <code>[[Ruby/Thread/thread variable get|thread_variable_get]]</code>: يُعيد التابع <code>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‎ في توثيق روبي الرسمي.]

مراجعة 13:34، 6 نوفمبر 2018

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

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

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

thread_variables array

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

يُعيد التابع thread_variables مصفوفة من أسماء المتغيرات المحلية في المهمة الفرعية (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_variable_set المتغيرا المحلي في المهمة الفرعية (thread local).
  • التابع thread_variable_get: يُعيد التابع thread_variable_get قيمة المتغير المحلي في المهمة الفرعية (thread local variable) الذي تم تعيينه.

مصادر