Changeset 617

Show
Ignore:
Timestamp:
12/13/07 19:48:35 (1 year ago)
Author:
blackhedd
Message:

additional documentation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • version_0/lib/em/processes.rb

    r616 r617  
    2626 
    2727module EventMachine 
     28 
     29        # EM::DeferrableChildProcess is a sugaring of a common use-case 
     30        # involving EM::popen. 
     31        # Call the #open method on EM::DeferrableChildProcess, passing 
     32        # a command-string. #open immediately returns an EM::Deferrable 
     33        # object. It also schedules the forking of a child process, which 
     34        # will execute the command passed to #open. 
     35        # When the forked child terminates, the Deferrable will be signalled 
     36        # and execute its callbacks, passing the data that the child process 
     37        # wrote to stdout. 
     38        # 
    2839        class DeferrableChildProcess < EventMachine::Connection 
    2940                include EventMachine::Deferrable 
    3041 
     42                # Sugars a common use-case involving forked child processes. 
     43                # #open takes a String argument containing an shell command 
     44                # string (including arguments if desired). #open immediately 
     45                # returns an EventMachine::Deferrable object, without blocking. 
     46                # 
     47                # It also invokes EventMachine#popen to run the passed-in 
     48                # command in a forked child process. 
     49                # 
     50                # When the forked child terminates, the Deferrable that 
     51                # #open calls its callbacks, passing the data returned 
     52                # from the child process. 
     53                # 
    3154                def self.open cmd 
    3255                        EventMachine.popen( cmd, DeferrableChildProcess ) 
  • version_0/tests/test_processes.rb

    r616 r617  
    3030class TestProcesses < Test::Unit::TestCase 
    3131 
     32        # EM::DeferrableChildProcess is a sugaring of a common use-case 
     33        # involving EM::popen. 
     34        # Call the #open method on EM::DeferrableChildProcess, passing 
     35        # a command-string. #open immediately returns an EM::Deferrable 
     36        # object. It also schedules the forking of a child process, which 
     37        # will execute the command passed to #open. 
     38        # When the forked child terminates, the Deferrable will be signalled 
     39        # and execute its callbacks, passing the data that the child process 
     40        # wrote to stdout. 
     41        # 
    3242        def test_deferrable_child_process 
    3343                ls = "" 
    3444                EM.run { 
    35                         d = EM::DeferrableChildProcess.open( "ls" ) 
     45                        d = EM::DeferrableChildProcess.open( "ls -ltr" ) 
    3646                        d.callback {|data_from_child| 
    3747                                ls = data_from_child