summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/thread.rb17
-rw-r--r--lib/timeout.rb1
2 files changed, 12 insertions, 6 deletions
diff --git a/lib/thread.rb b/lib/thread.rb
index a0e6967a280..fd51d6d5625 100644
--- a/lib/thread.rb
+++ b/lib/thread.rb
@@ -162,9 +162,11 @@ class Queue
end
t.run if t
end
- alias enq push
+ def enq(obj)
+ push(obj)
+ end
- def pop non_block=false
+ def pop(non_block=false)
Thread.critical = true
begin
loop do
@@ -182,8 +184,10 @@ class Queue
Thread.critical = false
end
end
- alias shift pop
- alias deq pop
+ def shift(non_block=false)
+ pop(non_block=false)
+ end
+ alias deq shift
def empty?
@que.length == 0
@@ -196,8 +200,9 @@ class Queue
def length
@que.length
end
- alias size length
-
+ def size
+ length
+ end
def num_waiting
@waiting.size
diff --git a/lib/timeout.rb b/lib/timeout.rb
index ba93a62f157..4e6f546e0c4 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -29,6 +29,7 @@ class TimeoutError<StandardError
end
def timeout(sec)
+ return yield if sec == nil
begin
x = Thread.current
y = Thread.start {