summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-03-17 08:58:21 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-03-17 08:58:21 +0000
commit5c13dd59db1ee6c04cdac4ce2ee97d5934115439 (patch)
treeb7027454a641e7c51404b316cb9b0b28f66acd3d /lib
parentd8f981b972aab02d1432abe1c9cadf0507945e77 (diff)
2000-03-17
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/debug.rb4
-rw-r--r--lib/matrix.rb1
-rw-r--r--lib/profile.rb25
-rw-r--r--lib/thread.rb53
4 files changed, 56 insertions, 27 deletions
diff --git a/lib/debug.rb b/lib/debug.rb
index 4497fd161d..b9a1d5f1c5 100644
--- a/lib/debug.rb
+++ b/lib/debug.rb
@@ -445,9 +445,9 @@ class DEBUGGER__
n += 1
break unless bind
if pos == n
- stdout.printf "--> #%d %s:%s%s\n", n, file, line, id != 0 ? ":in `#{id.id2name}'":""
+ stdout.printf "--> #%d %s:%s%s\n", n, file, line, id ? ":in `#{id.id2name}'":""
else
- stdout.printf " #%d %s:%s%s\n", n, file, line, id != 0 ? ":in `#{id.id2name}'":""
+ stdout.printf " #%d %s:%s%s\n", n, file, line, id ? ":in `#{id.id2name}'":""
end
end
end
diff --git a/lib/matrix.rb b/lib/matrix.rb
index 80d28148ac..a80b7dd9f1 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -420,6 +420,7 @@ class Matrix
vij = 0
0.upto(column_size - 1) do
|k|
+ p [k,j,m[k,j]]
vij += self[i, k] * m[k, j]
end
vij
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