summaryrefslogtreecommitdiff
path: root/lib/thread.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/thread.rb')
-rw-r--r--lib/thread.rb24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/thread.rb b/lib/thread.rb
index e5585c30bd..cb6d8c62fc 100644
--- a/lib/thread.rb
+++ b/lib/thread.rb
@@ -20,7 +20,7 @@ if $DEBUG
Thread.abort_on_exception = true
end
-#
+#
# ConditionVariable objects augment class Mutex. Using condition variables,
# it is possible to suspend while in the middle of a critical section until a
# resource becomes available.
@@ -31,7 +31,7 @@ end
#
# mutex = Mutex.new
# resource = ConditionVariable.new
-#
+#
# a = Thread.new {
# mutex.synchronize {
# # Thread 'a' now needs the resource
@@ -39,7 +39,7 @@ end
# # 'a' can now have the resource
# }
# }
-#
+#
# b = Thread.new {
# mutex.synchronize {
# # Thread 'b' has finished using the resource
@@ -55,7 +55,7 @@ class ConditionVariable
@waiters = []
@waiters_mutex = Mutex.new
end
-
+
#
# Releases the lock held in +mutex+ and waits; reacquires the lock on wakeup.
#
@@ -68,7 +68,7 @@ class ConditionVariable
mutex.sleep
end
end
-
+
#
# Wakes up the first thread in line waiting for this lock.
#
@@ -80,7 +80,7 @@ class ConditionVariable
retry
end
end
-
+
#
# Wakes up all threads waiting for this lock.
#
@@ -106,9 +106,9 @@ end
# Example:
#
# require 'thread'
-#
+#
# queue = Queue.new
-#
+#
# producer = Thread.new do
# 5.times do |i|
# sleep rand(i) # simulate expense
@@ -116,7 +116,7 @@ end
# puts "#{i} produced"
# end
# end
-#
+#
# consumer = Thread.new do
# 5.times do |i|
# value = queue.pop
@@ -124,7 +124,7 @@ end
# puts "consumed #{value}"
# end
# end
-#
+#
# consumer.join
#
class Queue
@@ -296,7 +296,7 @@ class SizedQueue < Queue
@queue_wait.push Thread.current
@mutex.sleep
end
-
+
@que.push obj
begin
t = @waiting.shift
@@ -305,7 +305,7 @@ class SizedQueue < Queue
retry
end
}
-
+
begin
t.run if t
rescue ThreadError