From 287a34ae0dfc23e4158f67cb7783d239f202c368 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 6 Mar 2009 03:56:38 +0000 Subject: * {ext,lib,test}/**/*.rb: removed trailing spaces. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/monitor.rb | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'lib/monitor.rb') diff --git a/lib/monitor.rb b/lib/monitor.rb index 31234819b8..00d85fae52 100644 --- a/lib/monitor.rb +++ b/lib/monitor.rb @@ -12,11 +12,11 @@ You can freely distribute/modify this library. This is a simple example. require 'monitor.rb' - + buf = [] buf.extend(MonitorMixin) empty_cond = buf.new_cond - + # consumer Thread.start do loop do @@ -26,7 +26,7 @@ This is a simple example. end end end - + # producer while line = ARGF.gets buf.synchronize do @@ -49,11 +49,11 @@ require 'thread' # +include+. For example: # # require 'monitor' -# +# # buf = [] # buf.extend(MonitorMixin) # empty_cond = buf.new_cond -# +# # # consumer # Thread.start do # loop do @@ -63,7 +63,7 @@ require 'thread' # end # end # end -# +# # # producer # while line = ARGF.gets # buf.synchronize do @@ -71,7 +71,7 @@ require 'thread' # empty_cond.signal # end # end -# +# # The consumer thread waits for the producer thread to push a line # to buf while buf.empty?, and the producer thread (main thread) # reads a line from ARGF and push it to buf, then call @@ -86,7 +86,7 @@ module MonitorMixin # class ConditionVariable class Timeout < Exception; end - + def wait(timeout = nil) if timeout raise NotImplementedError, "timeout is not implemented yet" @@ -100,33 +100,33 @@ module MonitorMixin @monitor.send(:mon_enter_for_cond, count) end end - + def wait_while while yield wait end end - + def wait_until until yield wait end end - + def signal @monitor.send(:mon_check_owner) @cond.signal end - + def broadcast @monitor.send(:mon_check_owner) @cond.broadcast end - + def count_waiters raise NotImplementedError end - + private def initialize(monitor) @@ -134,12 +134,12 @@ module MonitorMixin @cond = ::ConditionVariable.new end end - + def self.extend_object(obj) super(obj) obj.send(:mon_initialize) end - + # # Attempts to enter exclusive section. Returns +false+ if lock fails. # @@ -166,7 +166,7 @@ module MonitorMixin end @mon_count += 1 end - + # # Leaves exclusive section. # @@ -193,7 +193,7 @@ module MonitorMixin end end alias synchronize mon_synchronize - + # # FIXME: This isn't documented in Nutshell. # -- cgit v1.2.3