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

من موسوعة حسوب
< Ruby‏ | Thread
اذهب إلى التنقل اذهب إلى البحث
ط (مراجعة وتدقيق.)
 
سطر 1: سطر 1:
<noinclude>{{DISPLAYTITLE: التابع <code>thread_variable?‎‎</code> الخاص بالصنف <code>Thread</code> في روبي}}</noinclude>
+
<noinclude>{{DISPLAYTITLE: التابع <code>Thread.thread_variable?‎‎</code> في روبي}}</noinclude>
 
[[تصنيف: Ruby]]
 
[[تصنيف: Ruby]]
 
[[تصنيف: Ruby Method]]
 
[[تصنيف: Ruby Method]]
 
[[تصنيف: Ruby Thread]]
 
[[تصنيف: Ruby Thread]]
يُعيد التابع <code>thread_variable?‎</code> القيمة <code>true</code> إن كانت [[Ruby/String|السلسلة النصية]] أو الرمز المعطى <code>key</code> (انظر فقرة البنية العامة) موجودا كمتغير محلى [[Ruby/Thread|للمهمة الفرعية]] (thread-local variable).
+
يتحقق التابع <code>thread_variable?‎</code> إن كانت [[Ruby/String|السلسلة النصية]] أو الرمز المعطى موجودًا كمتغير محلي [[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/index operator|[]]]</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>
سطر 12: سطر 12:
 
[[Ruby/String|سلسلة نصية]] أو رمز.
 
[[Ruby/String|سلسلة نصية]] أو رمز.
  
==القيمة المُعادة==
+
==القيمة المعادة==
يُعيد التابع <code>thread_variable?‎</code> القيمة <code>true</code> إن كانت [[Ruby/String|السلسلة النصية]] أو الرمز المعطى <code>key</code> موجودا كمتغير محلى [[Ruby/Thread|للمهمة الفرعية]] (thread-local variable)، وإلا فسيعيد <code>false</code>.
+
تعاد القيمة <code>true</code> إن كانت [[Ruby/String|السلسلة النصية]] أو الرمز <code>key</code> المعطى موجودًا كمتغير محلي [[Ruby/Thread|للمهمة الفرعية]] (thread-local variable)، وإلا فستعاد القيمة <code>false</code>.
  
 
==أمثلة==
 
==أمثلة==
سطر 21: سطر 21:
 
me.thread_variable?(:oliver)    #=> true
 
me.thread_variable?(:oliver)    #=> true
 
me.thread_variable?(:stanley)  #=> false‎</syntaxhighlight>
 
me.thread_variable?(:stanley)  #=> false‎</syntaxhighlight>
==انظر أيضا==
+
==انظر أيضًا==
* التابع <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>: يُعيد قيمة المتغير المحلي في [[Ruby/Thread|المهمة الفرعية]] (thread local variable) الذي تم تعيينه.
 
==مصادر==
 
==مصادر==
*[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‎ في توثيق روبي الرسمي.]

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

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

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

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

thread_variable?(key) true or false

المعاملات

key‎

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

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

تعاد القيمة 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‎

انظر أيضًا

مصادر