Changeset 499

Show
Ignore:
Timestamp:
08/13/07 13:08:22 (1 year ago)
Author:
blackhedd
Message:

added EventMachine#reactor_running?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • version_0/ChangeLog

    r497 r499  
    555529Jul07: Added EventMachine::Protocols::Stomp. 
    565630Jul07: Added sys/stat.h to project.h to fix compilation bug on Darwin. 
     5713Aug07: Added EventMachine#reactor_running? 
     58 
  • version_0/lib/eventmachine.rb

    r496 r499  
    217217        @timers = {} 
    218218        begin 
     219            @reactor_running = true 
    219220            initialize_event_machine 
    220221            block and add_timer 0, block 
     
    222223        ensure 
    223224            release_machine 
     225            @reactor_running = false 
    224226        end 
    225227    end 
     
    944946        end 
    945947 
     948 
     949        # Tells you whether the EventMachine reactor loop is currently running. Returns true or 
     950        # false. Useful when writing libraries that want to run event-driven code, but may 
     951        # be running in programs that are already event-driven. In such cases, if EventMachine#reactor_running? 
     952        # returns false, your code can invoke EventMachine#run and run your application code inside 
     953        # the block passed to that method. If EventMachine#reactor_running? returns true, just 
     954        # execute your event-aware code. 
     955        # 
     956        # This method is necessary because calling EventMachine#run inside of another call to 
     957        # EventMachine#run generates a fatal error. 
     958        # 
     959        def self::reactor_running? 
     960                (@reactor_running || false) 
     961        end 
    946962 
    947963 
  • version_0/Rakefile

    r492 r499  
    338338end 
    339339 
     340desc "Test Running" 
     341task :test_running do |t| 
     342  run_tests t, :extension, "test_running*.rb" 
     343end 
     344 
    340345 
    341346desc "Build everything"