Ezra Zygmuntowicz
10/13/2006 8:21:00 PM
Hi Ara-
On Oct 13, 2006, at 12:30 PM, ara.t.howard@noaa.gov wrote:
> <snip>
>
> - detach method also sets up at_exit handler. extra protection
> from
> zombies.
>
> - ezra zygmuntowicz asked for a feature whereby a parent could
> be notified
> when a child exited. obviously such a mechanism should be
> both async
> and sync. to accomplish this the wait method was extended to
> support a
> callback with is either sync or async
>
> slave = Server.new{ Server.new }
>
> slave.wait and puts 'this is sync!'
>
> slave.wait(:non_block=>true){ 'this is async!' }
>
Awesome thanks Ara!
>
>
> <========< samples/b.rb >========>
>
> ~ > cat samples/b.rb
>
> require 'slave'
> #
> # if certain operations need to take place in the child only a
> block can be
> # used
> #
> class Server
> def connect_to_db
> "we only want to do this in the child process!"
> @connection = :postgresql
> end
> attr :connection
> end
>
> slave = Slave.new('object' => Server.new){|s| s.connect_to_db}
>
> server = slave.object
>
> p server.connection #=> :postgresql
This part if killer too. Very nice to be able to run the block in
the child! I am getting a ton of use out of Slave. Thanks for the
killer library.
Cheers-
-Ezra