lib/aw.rb in aw-0.2.0 vs lib/aw.rb in aw-0.2.1

- old
+ new

@@ -10,38 +10,34 @@ # # @api public module Aw # Runs the block inside a sub-process, and returns the computed value. # - # @param block [Proc] The code to run in a sub-process. - # # @example Computes `6 * 7` in a sub-process and returns `42` to the current process. # Aw.fork! { 6 * 7 } # => 42 # # @example Computes `nil + 1` in a sub-process and raises `NoMethodError` to the current process. # Aw.fork! { nil + 1 } # => raise NoMethodError (undefined method `+' for nil:NilClass) # # @raise [Exception] Exceptions raised in a block of code are propagated. # @return [#object_id] Returns the value that has been returned in the block. - def self.fork!(&block) + def self.fork!(&) read, write = ::IO.pipe - Fork.new(read, write).call(&block) + Fork.new(read, write).call(&) end # Runs the block inside a sub-process, and returns `true` if no exception is # thrown. Otherwise when an exception is raised, `false` is returned. # - # @param block [Proc] The code to run in a sub-process. - # # @example Computes `6 * 7` in a sub-process and returns `true` to the current process. # Aw.fork? { 6 * 7 } # => true # # @example Computes `nil + 1` in a sub-process and returns `false` to the current process. # Aw.fork? { nil + 1 } # => false # # @return [Boolean] Returns `true` if stat is successful, `false` if not. - def self.fork?(&block) - pid = ::Process.fork(&block) + def self.fork?(&) + pid = ::Process.fork(&) _, status = ::Process.wait2(pid) status.success? end end