صفحة الصنف ConditionVariable في روبي

من موسوعة حسوب
اذهب إلى التنقل اذهب إلى البحث

ترفع كائنات الصنفِ ConditionVariable الصنفَ Mutex. فباستخدام المتغيرات الشرطية، من الممكن إيقاف مهمة حرجة (critical section) في أثناء تنفيذها إلى حين إتاحة مورد ما.

إليك الأمثلة التالية:

mutex = Mutex.new
resource = ConditionVariable.new

a = Thread.new {
   mutex.synchronize {
     # Thread 'a' now needs the resource
     resource.wait(mutex)
     # 'a' can now have the resource
   }
}

b = Thread.new {
   mutex.synchronize {
     # Thread 'b' has finished using the resource
     resource.signal
   }
}

توابع الصنف العامة (Public Class Methods)

التابع polar

التابع rect

التابع rectangular 

مصادر