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

من موسوعة حسوب
< Ruby‏ | Thread
اذهب إلى التنقل اذهب إلى البحث
(أنشأ الصفحة ب'<noinclude>{{DISPLAYTITLE: التابع <code>thread_variables‎</code> الخاص بالصنف <code>Thread</code> في روبي}}</noinclude> تصنيف: Ruby...')
 
ط (مراجعة وتدقيق.)
 
(مراجعة متوسطة واحدة بواسطة مستخدم واحد آخر غير معروضة)
سطر 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/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>
==القيمة المُعادة==
+
==القيمة المعادة==
 +
تعاد [[Ruby/Array|مصفوفة]] من أسماء المتغيرات المحلية في [[Ruby/Thread|المهمة الفرعية]] (thread-local) على شكل رموز.
 +
 
 
==أمثلة==
 
==أمثلة==
 
مثال على استخدام التابع <code>thread_variables‎</code>:
 
مثال على استخدام التابع <code>thread_variables‎</code>:
سطر 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>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>: يعين متغير محلي محدَّد في [[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>: يُعيد قيمة المتغير المحلي في المهمة الفرعية (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) الذي تم تعيينه.

مصادر