الفرق بين المراجعتين ل"Ruby/Thread/thread variable-3F"

من موسوعة حسوب
< Ruby‏ | Thread
اذهب إلى التنقل اذهب إلى البحث
(أنشأ الصفحة ب'<noinclude>{{DISPLAYTITLE: التابع <code>thread_variable?‎‎</code> الخاص بالصنف <code>Thread</code> في روبي}}</noinclude> تصنيف: Ruby...')
 
سطر 3: سطر 3:
 
[[تصنيف: Ruby Method]]
 
[[تصنيف: Ruby Method]]
 
[[تصنيف: Ruby Thread]]
 
[[تصنيف: Ruby Thread]]
يُعيد التابع <code>thread_variable?‎</code> القيمة <code>true</code> إن كانت [[Ruby/String|السلسلة النصية]] (أو الرمز) موجودة كمتغير محلى [[Ruby/Thread|المهمة الفرعية]] (thread-local variable).
+
يُعيد التابع <code>thread_variable?‎</code> القيمة <code>true</code> إن كانت [[Ruby/String|السلسلة النصية]] أو الرمز المعطى <code>key</code> (انظر فقرة البنية العامة) موجودا كمتغير محلى [[Ruby/Thread|للمهمة الفرعية]] (thread-local variable).
  
 
+
لاحظ أن هذه المتغيرات ليست متغيرات محلية [[Ruby/Fiber|الألياف]] (fiber local variables).  يرجى الاطلاع على الصفحتين <code>[[Ruby/Thread/index operator|[]]]</code> و <code>[[Ruby/Thread/thread_variable_get|thread_variable_get]]</code> لمزيد من التفاصيل.
 
 
لاحظ أن هذه المتغيرات ليست متغيرات محلية [[Ruby/Fiber|الألياف]] (fiber local variables).  يرجى الاطلاع على الصفحتين <code>[[Ruby/Thread/5B-5D|#[]]]</code> و <code>[[Ruby/Thread/thread_variable_get|#thread_variable_get]]</code> لمزيد من التفاصيل.
 
 
==البنية العامة==
 
==البنية العامة==
 
<syntaxhighlight lang="ruby">thread_variable?(key)→ true or false‎</syntaxhighlight>
 
<syntaxhighlight lang="ruby">thread_variable?(key)→ true or false‎</syntaxhighlight>
 
==المعاملات==
 
==المعاملات==
 
===<code>key‎</code>===
 
===<code>key‎</code>===
 +
[[Ruby/String|سلسلة نصية]] أو رمز.
 +
 
==القيمة المُعادة==
 
==القيمة المُعادة==
 +
يُعيد التابع <code>thread_variable?‎</code> القيمة <code>true</code> إن كانت [[Ruby/String|السلسلة النصية]] أو الرمز المعطى <code>key</code> موجودا كمتغير محلى [[Ruby/Thread|للمهمة الفرعية]] (thread-local variable)، وإلا فسيعيد <code>false</code>.
 +
 
==أمثلة==
 
==أمثلة==
 
مثال على استخدام التابع <code>thread_variable?‎</code>:
 
مثال على استخدام التابع <code>thread_variable?‎</code>:
سطر 20: سطر 22:
 
me.thread_variable?(:stanley)  #=> false‎</syntaxhighlight>
 
me.thread_variable?(:stanley)  #=> false‎</syntaxhighlight>
 
==انظر أيضا==
 
==انظر أيضا==
* التابع <code>[[Ruby/Thread/terminate|terminate]]</code>: ينهي التابع <code>terminate</code> [[Ruby/Thread|المهمة الفرعية]] <code>thr</code> ويُجدوِل [[Ruby/Thread|مهمة فرعية]] أخرى ليتم تشغيلها.
+
* التابع <code>[[Ruby/Thread/thread_variable_get|thread_variable_get]]</code>: يُعيد التابع <code>thread_variable_get</code> قيمة المتغير المحلي في [[Ruby/Thread|المهمة الفرعية]] (thread local variable) الذي تم تعيينه.
* التابع <code>[[Ruby/Thread/thread_variable_get|thread_variable_get]]</code>: يُعيد التابع <code>thread_variable_get</code> قيمة المتغير المحلي في [[Ruby/Thread|المهمة الفرعية]] (thread local variable) الذي تم تعيينه.  لاحظ أن هذه المتغيرات تختلف عن القيم محلية [[Ruby/Fiber|الألياف]] (fiber local values).  بالنسبة للقيم محلية [[Ruby/Fiber|الألياف]] (fiber local values)، يرجى الاطلاع على <code>[[Ruby/Thread/5B-5D|#[]]]</code> و <code>[[Ruby/Thread/5B-5D-3D|#[]=]]</code>.
 
 
==مصادر==
 
==مصادر==
 
*[http://ruby-doc.org/core-2.5.1/Thread.html#method-i-thread_variable-3F قسم  التابع thread_variable?‎ في الصنف Thread‎ في توثيق روبي الرسمي.]
 
*[http://ruby-doc.org/core-2.5.1/Thread.html#method-i-thread_variable-3F قسم  التابع thread_variable?‎ في الصنف Thread‎ في توثيق روبي الرسمي.]

مراجعة 12:56، 6 نوفمبر 2018

يُعيد التابع thread_variable?‎ القيمة true إن كانت السلسلة النصية أو الرمز المعطى key (انظر فقرة البنية العامة) موجودا كمتغير محلى للمهمة الفرعية (thread-local variable).

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

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

thread_variable?(key) true or false

المعاملات

key‎

سلسلة نصية أو رمز.

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

يُعيد التابع thread_variable?‎ القيمة true إن كانت السلسلة النصية أو الرمز المعطى key موجودا كمتغير محلى للمهمة الفرعية (thread-local variable)، وإلا فسيعيد false.

أمثلة

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

me = Thread.current
me.thread_variable_set(:oliver, "a")
me.thread_variable?(:oliver)    #=> true
me.thread_variable?(:stanley)   #=> false‎

انظر أيضا

مصادر