summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-03-23 04:14:31 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-03-23 04:14:31 +0000
commit6c2be430400d53832eb05d5b617e495121e9241f (patch)
tree80abe89f64ec3e762f274c6da25385fdd3bfdf1c /lib
parent8f5c38d5fd0f2ef165a71f44b9c5410d1e0743bb (diff)
2000-03-23
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_4@647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/profile.rb25
-rw-r--r--lib/thread.rb53
2 files changed, 53 insertions, 25 deletions
diff --git a/lib/profile.rb b/lib/profile.rb
index e4b1b4b189..d94b09da9e 100644
--- a/lib/profile.rb
+++ b/lib/profile.rb
@@ -3,7 +3,7 @@ module Profiler__
Start = Float(Time.times[0])
top = "toplevel".intern
Stack = [[0, 0, top]]
- MAP = {top => [1, 0, 0, "#toplevel"]}
+ MAP = {"#toplevel" => [1, 0, 0, "#toplevel"]}
p = proc{|event, file, line, id, binding, klass|
case event
@@ -13,17 +13,18 @@ module Profiler__
when "return", "c-return"
now = Float(Time.times[0])
tick = Stack.pop
- data = MAP[id]
+ name = klass.to_s
+ if name.nil? then name = '' end
+ if klass.kind_of? Class
+ name += "#"
+ else
+ name += "."
+ end
+ name += id.id2name
+ data = MAP[name]
unless data
- name = klass.to_s
- if name.nil? then name = '' end
- if klass.kind_of? Class
- name += "#"
- else
- name += "."
- end
- data = [0.0, 0.0, 0.0, name+id.id2name]
- MAP[id] = data
+ data = [0.0, 0.0, 0.0, name]
+ MAP[name] = data
end
data[0] += 1
cost = now - tick[0]
@@ -36,7 +37,7 @@ module Profiler__
set_trace_func nil
total = Float(Time.times[0]) - Start
if total == 0 then total = 0.01 end
- MAP[:toplevel][1] = total
+ MAP["#toplevel"][1] = total
# f = open("./rmon.out", "w")
f = STDERR
data = MAP.values.sort!{|a,b| b[2] <=> a[2]}
diff --git a/lib/thread.rb b/lib/thread.rb
index 22610f2992..9edda48abe 100644
--- a/lib/thread.rb
+++ b/lib/thread.rb
@@ -63,10 +63,14 @@ class Mutex
def unlock
return unless @locked
Thread.critical = true
- t = @waiting.shift
@locked = false
+ begin
+ t = @waiting.shift
+ t.wakeup if t
+ rescue ThreadError
+ retry
+ end
Thread.critical = false
- t.run if t
self
end
@@ -82,9 +86,13 @@ class Mutex
def exclusive_unlock
return unless @locked
Thread.exclusive do
- t = @waiting.shift
@locked = false
- t.wakeup if t
+ begin
+ t = @waiting.shift
+ t.wakeup if t
+ rescue ThreadError
+ retry
+ end
yield
end
self
@@ -105,8 +113,12 @@ class ConditionVariable
end
def signal
- t = @waiters.shift
- t.run if t
+ begin
+ t = @waiters.shift
+ t.run if t
+ rescue ThreadError
+ retry
+ end
end
def broadcast
@@ -116,7 +128,10 @@ class ConditionVariable
@waiters.clear
end
for t in waiters0
- t.run
+ begin
+ t.run
+ rescue ThreadError
+ end
end
end
end
@@ -133,9 +148,13 @@ class Queue
def push(obj)
Thread.critical = true
@que.push obj
- t = @waiting.shift
+ begin
+ t = @waiting.shift
+ t.wakeup if t
+ rescue ThreadError
+ retry
+ end
Thread.critical = false
- t.run if t
end
alias enq push
@@ -201,8 +220,12 @@ class SizedQueue<Queue
@max = max
Thread.critical = false
diff.times do
- t = @queue_wait.shift
- t.run if t
+ begin
+ t = @queue_wait.shift
+ t.run if t
+ rescue ThreadError
+ retry
+ end
end
end
max
@@ -221,8 +244,12 @@ class SizedQueue<Queue
def pop(*args)
Thread.critical = true
if @que.length < @max
- t = @queue_wait.shift
- t.run if t
+ begin
+ t = @queue_wait.shift
+ t.run if t
+ rescue ThreadError
+ retry
+ end
end
super
end