yarv-diff:311
From: ko1 atdot.net
Date: 27 Feb 2006 02:27:32 -0000
Subject: [yarv-diff:311] r476 - in trunk: . lib
Author: aamine
Date: 2006-02-27 11:27:32 +0900 (Mon, 27 Feb 2006)
New Revision: 476
Modified:
trunk/ChangeLog
trunk/lib/thread.rb
Log:
* lib/thread.rb (Queue#pop): faster code. [yarv-dev:973]
* lib/thread.rb (Queue#pop): avoid to push same thread in to @waiting.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-02-23 14:33:03 UTC (rev 475)
+++ trunk/ChangeLog 2006-02-27 02:27:32 UTC (rev 476)
@@ -4,6 +4,14 @@
# from Mon, 03 May 2004 01:24:19 +0900
#
+2006-02-27(Mon) 11:27:19 +0900 Minero Aoki <aamine loveruby.net>
+
+ * lib/thread.rb (Queue#pop): faster code. [yarv-dev:973]
+
+ * lib/thread.rb (Queue#pop): avoid to push same thread in to
+ @waiting.
+
+
2006-02-23(Thu) 23:32:53 +0900 Minero Aoki <aamine loveruby.net>
* lib/open3.rb: imported from Ruby CVS trunk HEAD (rev 1.12).
Modified: trunk/lib/thread.rb
===================================================================
--- trunk/lib/thread.rb 2006-02-23 14:33:03 UTC (rev 475)
+++ trunk/lib/thread.rb 2006-02-27 02:27:32 UTC (rev 476)
@@ -176,17 +176,19 @@
# thread isn't suspended, and an exception is raised.
#
def pop(non_block=false)
- raise ThreadError, "queue empty" if non_block
+ @mutex.synchronize{
+ if @que.empty?
+ raise ThreadError, "queue empty" if non_block
+ @waiting.push Thread.current
+ else
+ return @que.shift
+ end
+ }
while true
@mutex.synchronize{
- if @que.empty?
- @waiting.push Thread.current
- @mutex.unlock_and_stop
- @mutex.lock
- else
- return @que.shift
- end
+ return @que.shift unless @que.empty?
}
+ Thread.pass
end
end
@@ -201,7 +203,7 @@
alias deq pop
#
- # Returns +true+ is the queue is empty.
+ # Returns +true+ if the queue is empty.
#
def empty?
@que.empty?
--
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml