diff -ur rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/browser.lib.rb rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/browser.lib.rb
--- rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/browser.lib.rb 2004-11-28 14:41:35.000000000 +0100
+++ rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/browser.lib.rb 2004-12-05 13:58:40.000000000 +0100
@@ -12,7 +12,7 @@
def windowsbrowser
$stderr.puts "Looking for default browser..."
- filetype = nil
+ filetype = "htmlfile"
application = nil
begin
@@ -71,13 +71,10 @@
end
end
- catch :once do
- HTTPServer.serve([port, io]) do |req, resp|
- resp << html
- resp.flush
+ HTTPServer.serve([port, io]) do |req, resp|
+ resp << html
- throw :once
- end
+ resp.stop
end
end
diff -ur rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/ftools.lib.rb rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/ftools.lib.rb
--- rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/ftools.lib.rb 2004-11-28 14:41:35.000000000 +0100
+++ rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/ftools.lib.rb 2004-12-05 13:58:40.000000000 +0100
@@ -86,22 +86,6 @@
res
end
-
- def self.findandchangecontent(entry=nil, mask=nil)
- Dir.find(entry, mask).each do |file|
- unless File.directory?(file)
- data1 = File.open(file){|f| f.read}
-
- data2 = yield(data1)
-
- if data2 != data1
- $stderr.puts "Changing #{file} ..."
-
- File.open(file, "w"){|f| f.write data2}
- end
- end
- end
- end
end
class File
diff -ur rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/net.lib.rb rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/net.lib.rb
--- rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-11-28 14:41:35.000000000 +0100
+++ rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-12-05 13:58:40.000000000 +0100
@@ -1,8 +1,6 @@
require "ev/ruby"
require "ev/ftools"
-#alias old_timeout :timeout
require "net/http"
-#alias timeout :old_timeout
require "socket"
require "uri"
require "cgi"
@@ -565,6 +563,8 @@
class Response < Hash
attr_writer :response
attr_reader :cookies
+ attr_reader :stop
+ attr_reader :at_stop
def initialize(io)
@io = io
@@ -572,6 +572,8 @@
@cookies = {}
@data = ""
@syncd = false
+ @stop = false
+ @at_stop = lambda{}
end
def flush
@@ -606,11 +608,21 @@
def inspect
"(Response: %s)" % [@response, @data].join(", ")
end
+
+ def stop(&block)
+ @stop = true
+ @at_stop = block unless block.nil?
+ end
+
+ def stop?
+ @stop
+ end
end
-class HTTPServer
- @@times = {}
+class HTTPServerException < Exception
+end
+class HTTPServer
def self.serve(portio=80, remote=false, auth=nil, realm="ev/net")
port, server = portio
@@ -625,43 +637,85 @@
end
if not server.nil?
- loop do
- io = server.accept
+ count = 0
- catch :rwd_io_error do
- begin
- req = Request.new(io)
- resp = Response.new(io)
- rescue
- throw :rwd_io_error
- end
-
- begin
- ip = req.peeraddr[3]
- com = req.request.to_s.strip + ip
- rescue NameError
- throw :rwd_io_error
- end
+ at_exit do
+ $stderr.puts "Received #{count} requests"
+ end
- if (not remote) or (remote and (auth.nil? or auth.empty? or authenticate(auth, realm, req, resp)))
- @@times[com]=Time.new.to_f if not @@times.include?(com)
+ serverthread =
+ Thread.new do
+ mutex = Mutex.new
- #$stderr.puts "#{Time.new.strftime("%H:%M:%S")}: #{ip}: #{((Time.new.to_f - @@times[com]).to_s + "0"*4)[0..4]}: > #{req.request.to_s.strip}"
+ Thread.current["threads"] = []
- yield(req, resp)
+ every(1, Thread.current) do |thread|
+ mutex.synchronize do
+ thread["threads"].delete_if{|t| (not t.alive?)}
+ end
+ end
- $stderr.puts "#{Time.new.strftime("%H:%M:%S")}: #{ip}: #{((Time.new.to_f - @@times[com]).to_s + "0"*4)[0..4]}: < #{req.request.to_s.strip}"
+ loop do
+ io = server.accept
+ count += 1
+
+ thread =
+ Thread.new(Thread.current, count) do |parentthread, count2|
+ stop = false
+
+ begin
+ begin
+ req = Request.new(io)
+ resp = Response.new(io)
+ rescue
+ raise HTTPServerException
+ end
+
+ begin
+ ip = req.peeraddr[3]
+ rescue NameError
+ raise HTTPServerException
+ end
+
+ if (not remote) or (remote and (auth.nil? or auth.empty? or authenticate(auth, realm, req, resp)))
+ $stderr.puts "#{count2}, #{Time.new.strftime("%Y-%m-%d.%H:%M:%S")}, #{ip}, #{req.request.to_s.strip}"
+
+ begin
+ yield(req, resp)
+ rescue Exception => e
+ mutex.synchronize do
+ $stderr.puts e.class.to_s + ": " + e.message
+ $stderr.puts e.backtrace.collect{|s| "\t"+s}.join("\n")
+ end
+ end
+
+ stop = true if resp.stop?
+ end
+
+ begin
+ resp.flush
+ rescue
+ raise HTTPServerException
+ end
+ rescue HTTPServerException
+ end
- @@times.delete(com)
- end
+ parentthread["stop"] = resp if stop
+ end
- begin
- resp.flush
- rescue
- throw :rwd_io_error
- end
+ mutex.synchronize do
+ Thread.current["threads"] << thread
+ end
end
end
+
+ sleep 0.1 while not serverthread["stop"]
+
+ serverthread["threads"].each {|t| t.join}
+
+ serverthread["stop"].at_stop.call
+
+ serverthread.kill
end
end
diff -ur rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/ruby.lib.rb rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/ruby.lib.rb
--- rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2004-11-28 14:41:35.000000000 +0100
+++ rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2004-12-05 13:58:40.000000000 +0100
@@ -1,5 +1,10 @@
require "cgi"
require "rbconfig"
+require "thread"
+
+Thread.abort_on_exception = true
+
+$DEBUG = ($DEBUG or ENV["RUBYDEBUG"] or false)
#tekens = ´\w\~\@\#\$\%\^\&\*\-\+´
tekens = ´^\s\r\n\`\!\(\)\[\]\{\}\<\>\,\.\/\?\\\|\=\;\:\"´
@@ -645,19 +650,19 @@
def after(seconds, *args)
if not seconds.nil? and not seconds.zero?
- Thread.new(*args) do |*args|
+ Thread.new(*args) do |*args2|
sleep seconds
- yield(*args)
+ yield(*args2)
end
end
end
def every(seconds, *args)
if not seconds.nil? and not seconds.zero?
- Thread.new(*args) do |*args|
+ Thread.new(*args) do |*args2|
loop do
sleep seconds
- yield(*args)
+ yield(*args2)
end
end
end
@@ -740,38 +745,44 @@
end
end
- if $bm.nil?
- require "ev/bm"
+ label = label.to_s
+ res = nil
+
+ $bm_mutex = ($bm_mutex or Mutex.new)
+
+ $bm_mutex.synchronize do
+ if $bm.nil?
+ require "ev/bm"
+
+ $bm = {}
- $bm = {}
+ at_exit do
+ format1 = "%10s %10s %10s %10s %10s %10s %10s"
+ format2 = "%10s %10.6f %10.6f %10.6f %10.6f %10.6f %10d"
- at_exit do
- format1 = "%10s %10s %10s %10s %10s %10s %10s"
- format2 = "%10s %10.6f %10.6f %10.6f %10.6f %10.6f %10d"
-
- $stderr.puts format1 % ["LABEL", "USERCPU", "SYSCPU", "CUSERCPU", "CSYSCPU", "ELAPSED", "TIMES"]
- $bm.sort{|a, b| [a[1], a[0]] <=> [b[1], b[0]]}.each do |k, v|
- $stderr.puts format2 % [k, *v]
+ $stderr.puts format1 % ["LABEL", "USERCPU", "SYSCPU", "CUSERCPU", "CSYSCPU", "ELAPSED", "TIMES"]
+ $bm.sort{|a, b| [a[1], a[0]] <=> [b[1], b[0]]}.each do |k, v|
+ $stderr.puts format2 % [k, *v]
+ end
end
end
- end
-
- label = label.to_s
- res = nil
- $bm[label] = [0.0]*5 + [0] unless $bm.include?(label)
+ $bm[label] = [0.0]*5 + [0] unless $bm.include?(label)
+ end
if block_given?
bm = Benchmark.measure{res = yield}
bma = bm.to_a # [dummy label, user CPU time, system CPU time, childrens user CPU time, childrens system CPU time, elapsed real time]
- 0.upto(4) do |n|
- $bm[label][n] += bma[n+1]
+ $bm_mutex.synchronize do
+ 0.upto(4) do |n|
+ $bm[label][n] += bma[n+1]
+ end
+
+ $bm[label][5] += 1
end
end
- $bm[label][5] += 1
-
res
end
diff -ur rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/rwd.lib.rb rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/rwd.lib.rb
--- rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-11-28 14:41:35.000000000 +0100
+++ rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-12-05 13:58:40.000000000 +0100
@@ -2,6 +2,7 @@
require "ev/xml"
require "ev/net"
require "ev/browser"
+require "ev/thread"
require "md5"
require "rbconfig"
@@ -20,7 +21,6 @@
$rwd_files = File.expand_path("rwd_files", Dir.pwd)
$rwd_html = {}
-
ARGV.delete_if do |arg|
arg =~ /^--rwd-/
end
@@ -45,7 +45,7 @@
Hash.file(rcfile).each do |k, v|
#$stderr.puts "Setting #{k} to \"#{v}\" ..."
- ENV[k] = v
+ ENV[k] = v unless ENV.include?(k)
end
end
@@ -92,7 +92,7 @@
if emptyline.nil?
a = self
else
- a = [emptyline].concat self
+ a = [emptyline].concat(self)
end
a.numsort.collect{|s| "<option>#{s.to_html}</option>" }.join("\n")
@@ -202,11 +202,11 @@
values = [] if values.nil?
options = {}
- if File.file?(oldlocation("constraints.csv"))
- table = File.basename(@file).gsub(/\.csv$/, "")
+ if File.file?(oldlocation("constraints.tsv"))
+ table = File.basename(@file).gsub(/\.tsv$/, "")
- CSVFile.new(oldlocation("constraints.csv")).subset(["Table", "Constraint"], [table, "key"], ["Column", "Value"]).values.each do |column, table2|
- options[column] = CSVFile.new(oldlocation("#{table2}.csv")).keys.collect{|a| a.join("\t")}
+ TSVFile.new(oldlocation("constraints.tsv")).subset(["Table", "Constraint"], [table, "key"], ["Column", "Value"]).values.each do |column, table2|
+ options[column] = TSVFile.new(oldlocation("#{table2}.tsv")).keys.collect{|a| a.join("\t")}
end
end
@@ -967,11 +967,7 @@
def render(res, path, post, download, downloadfile, pda)
done = self["object"].render(res, path, post, download, downloadfile, pda, @sessionid)
- if done
- res.gsub!(/\$RWD_SESSION\$/, "")
- else
- res.gsub!(/\$RWD_SESSION\$/, "#{@sessionid}")
- end
+ res.gsub!(/\$RWD_SESSION\$/, done ? "" : "#{@sessionid}")
return done
end
@@ -1000,13 +996,21 @@
#if ENV["RWDBROWSER"].downcase =~ /iexplore/ # ???
#@ie = IE.new("http://localhost:#{port}/")
#else
- if windows?
- system("#{ENV["RWDBROWSER"]} \"http://localhost:#{port}/\"".gsub(/%port%/, port.to_s))
- elsif cygwin?
- system("#{ENV["RWDBROWSER"].gsub(/\\/, "/").gsub(/ /, "\ ")} \"http://localhost:#{port}/\"".gsub(/%port%/, port.to_s))
- else
- system("#{ENV["RWDBROWSER"]} \"http://localhost:#{port}/\"".gsub(/%port%/, port.to_s))
+ browser = ENV["RWDBROWSER"]
+ url = "http://localhost:%s/" % [port]
+
+ if cygwin?
+ browser.gsub!(/\\/, "/")
+ browser.gsub!(/ /, "\ ")
end
+
+ re = /[$%]1\b/
+ command = "%s \"%s\"" % [browser, url]
+ command = browser.gsub(re, url) if browser =~ re
+
+ command.gsub!(/%port%/, port.to_s)
+
+ system(command)
#end
puts "The browser has terminated."
@@ -1016,12 +1020,15 @@
# Start server.
- catch :rwd_exit do
- portio = port
- portio = [port, io] unless io.nil?
- HTTPServer.serve(portio, (not auth.nil?)) do |req, resp|
+ portio = port
+ portio = [port, io] unless io.nil?
+ threadlimiter = ThreadLimiter.new(1)
+
+ HTTPServer.serve(portio, (not auth.nil?)) do |req, resp|
+ threadlimiter.wait do
+
vars = req.vars.dup
- pad = req.request.path
+ pad = (req.request.path or "/")
if auth.kind_of? String
file = "#{home}/#{auth}"
@@ -1034,28 +1041,26 @@
#oldsessionid = vars["rwd_session"]
oldsessionid = req.cookies["sessionid"]
- # Retrieve session.
+ # Retrieve session.
session = @sessions[oldsessionid]
- # Eventually create new session.
+ # Eventually create new session.
if session.nil?
+ sessionid = MD5.new(req.peeraddr[3].to_s + @object.inspect.to_s + ("%1.6f" % Time.now.to_f)).to_s while (sessionid == nil or @sessions.include?(sessionid))
+ session = RWDSession.new(sessionid)
+
if auth.nil?
- sessionid = MD5.new(req.peeraddr[3].to_s + @object.inspect.to_s).to_s
- session = RWDSession.new(sessionid)
session["object"] = @object
else
- sessionid = nil
- sessionid = MD5.new(Time.new.to_s + req.peeraddr[3].to_s + @object.inspect.to_s).to_s while (sessionid.nil? or @sessions.include?(sessionid))
- session = RWDSession.new(sessionid)
session["object"] = @object.clone
end
if oldsessionid.nil? or oldsessionid.empty?
- if not auth.nil? and not auth.empty? and not session.authenticated and pad != "/pixel.gif"
+ if not auth.nil? and not auth.empty? and not session.authenticated and pad != "/rwd_pixel.gif"
- # Check authentication
+ # Check authentication
us = vars["rwd_a"]
pa = vars["rwd_b"]
@@ -1080,15 +1085,15 @@
vars = {}
end
- # Avoid timeout.
+ # Avoid timeout.
session.touch
if pad == "/"
- # Serve methods/callbacks.
+ # Serve methods/callbacks.
- # Build new page.
+ # Build new page.
download = ""
downloadfile = ""
@@ -1119,29 +1124,29 @@
@sessions.delete(session.sessionid)
end
- # Eventually delete this session.
+ # Eventually delete this session.
if done
@sessions.delete(session.sessionid)
if @localbrowsing
- resp.flush
+ resp.stop
if @browserstarted and not @browserthread.nil? and @browserthread.alive?
- puts "Waiting for the browser to terminate..."
+ resp.stop do
+ puts "Waiting for the browser to terminate..."
- @browserthread.join
+ @browserthread.join
+ end
end
-
- throw :rwd_exit
end
end
else
- # Serve files.
+ # Serve files.
- if pad == "/pixel.gif"
+ if pad == "/rwd_pixel.gif"
resp["Cache-Control"] = "max-age=86400"
resp["Content-Type"] = "image/gif"
resp << $rwd_pixel
@@ -1169,6 +1174,7 @@
end
end
+
end
end
end
@@ -1181,7 +1187,7 @@
<head>
<title>%TITLE%</title>
- <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´>
+ <!-- <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´> -->
<meta http-equiv=´Content-Style-Type´ content=´text/css´>
<link rel=´shortcut icon´ href=´%LOGO%´>
@@ -1279,81 +1285,81 @@
<table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´>
<tr align=´center´>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
</tr>
<tr align=´center´>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
</tr>
<tr align=´center´>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
</tr>
<tr align=´center´>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
</tr>
<tr align=´center´>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
</tr>
<tr align=´center´>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
<td align=´center´>
@@ -1381,7 +1387,7 @@
</tr>
<tr align=´center´>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´%WIDTH2%´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´%WIDTH2%´></td>
</tr>
<tr align=´center´>
@@ -1398,81 +1404,81 @@
</td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
</tr>
<tr align=´center´>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
</tr>
<tr align=´center´>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
</tr>
<tr align=´center´>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
</tr>
<tr align=´center´>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
</tr>
<tr align=´center´>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td>
</tr>
</table>
@@ -1492,7 +1498,7 @@
<head>
<title>%TITLE%</title>
- <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´>
+ <!-- <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´> -->
<meta http-equiv=´Content-Style-Type´ content=´text/css´>
<link rel=´shortcut icon´ href=´%LOGO%´>
@@ -1622,7 +1628,7 @@
</tr>
<tr align=´center´>
- <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´%WIDTH2%´></td>
+ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´%WIDTH2%´></td>
</tr>
<tr align=´center´>
@@ -1657,7 +1663,7 @@
<head>
<title>%TITLE%</title>
- <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´>
+ <!-- <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´> -->
<link rel=´shortcut icon´ href=´%LOGO%´>
diff -ur rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/thread.lib.rb rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/thread.lib.rb
--- rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/thread.lib.rb 2004-12-05 13:58:45.000000000 +0100
+++ rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/thread.lib.rb 2004-12-05 13:58:40.000000000 +0100
@@ -0,0 +1,63 @@
+require "ev/ruby"
+require "thread"
+
+class FakeThread
+ def initialize(*args)
+ yield(*args)
+ end
+
+ def join
+ end
+end
+
+class ThreadLimiter
+ def initialize(limit)
+ @limit = limit
+ @count = 0
+ @threads = []
+ @mutex = Mutex.new
+ @cv = ConditionVariable.new
+
+ every(1) do
+ @mutex.synchronize do
+ @threads.dup.each do |t|
+ unless t.alive?
+ $stderr.puts "Found dead thread."
+
+ @threads.delete(t)
+
+ @count -= 1
+
+ @cv.signal
+ end
+ end
+ end
+ end
+ end
+
+ def wait
+ if block_given?
+ self.wait
+ yield
+ self.signal
+ else
+ @mutex.synchronize do
+ @threads << Thread.current
+
+ @count += 1
+
+ @cv.wait(@mutex) if @count > @limit
+ end
+ end
+ end
+
+ def signal
+ @mutex.synchronize do
+ @threads.delete(Thread.current)
+
+ @count -= 1
+
+ @cv.signal
+ end
+ end
+end