This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'eventmachine' | |
| module EM::Protocols::Memcache | |
| include EM::Protocols::LineText2 | |
| include EM::Deferrable | |
| Cstored = 'STORED'.freeze | |
| Cend = 'END'.freeze | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if __FILE__ == $0 | |
| require 'em/spec' | |
| class TestConnection | |
| include EM::P::Memcache | |
| def send_data data | |
| sent_data << data | |
| end | |
| def sent_data | |
| @sent_data ||= '' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/ext/rubymain.cpp b/ext/rubymain.cpp | |
| index 1e0dd6f..4eb7738 100644 | |
| --- a/ext/rubymain.cpp | |
| +++ b/ext/rubymain.cpp | |
| @@ -33,24 +33,36 @@ static VALUE EmConnection; | |
| static VALUE Intern_at_signature; | |
| static VALUE Intern_at_timers; | |
| static VALUE Intern_at_conns; | |
| +static VALUE Intern_at_error_handler; | |
| static VALUE Intern_event_callback; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ReactorLatency < Graph | |
| name 'reactor_latency' | |
| vlabel 'microseconds' | |
| scale 'no' | |
| category 'application' | |
| next_tick 'next_tick latency' | |
| timer 'timer latency' | |
| def self.fetch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # | |
| # Use to filter strace output associated with ruby/EM processes running with EM.epoll | |
| # sudo strace -ttTp <ruby process pid> -o ruby.strace | |
| # cat ruby.strace | ./em-strace-filter.rb > filtered.strace | |
| # | |
| require 'time' | |
| begin_time = nil | |
| end_time = nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ ./miniruby -e 'class T; end; a = 1..1; b = "hi"; c = []; d = Hash.new; e = T.new; p GC.dump_heap' | |
| 0x00154750 allocated @ -e:1 is an OBJECT of type: T | |
| 0x0015476c allocated @ -e:1 is a HASH which has data | |
| 0x00154788 allocated @ -e:1 is an ARRAY of len: 0. | |
| 0x001547c0 allocated @ -e:1 is a STRING (ELTS_SHARED) which has len: 2 and val: hi | |
| 0x001547dc allocated @ -e:1 is a STRING which has len: 1 and val: T | |
| 0x001547f8 allocated @ -e:1 which is a CLASS no name - maybe anon class? | |
| 0x00154814 allocated @ -e:1 which is a CLASS named: T inherits from Object | |
| 0x00154a98 allocated @ -e:1 is a STRING which has len: 2 and val: hi | |
| 0x00154b40 allocated @ -e:1 is an OBJECT of type: Range |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class GCTime < Graph | |
| name 'gc_time' | |
| title 'Time spent in GC' | |
| vlabel 'microseconds' | |
| category 'gc' | |
| gc_len 'musec in GC' | |
| def self.fetch | |
| if GC.respond_to? :time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'eventmachine' | |
| ### EM::run takes over the process | |
| # puts 1 | |
| # EM.run{ | |
| # require 'mycode' | |
| # } | |
| # puts 3 # this will never happen |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # async_sinatra_example.ru | |
| require 'sinatra' | |
| # Normally Sinatra::Base expects that the completion of a request is | |
| # determined by the block exiting, and returning a value for the body. | |
| # | |
| # In an async environment, we want to tell the webserver that we're not going | |
| # to provide a response now, but some time in the future. | |
| # | |
| # The a* methods provide a method for doing this, by informing the server of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/lib/nanite/agent.rb b/lib/nanite/agent.rb | |
| index 8cb8900..87da714 100644 | |
| --- a/lib/nanite/agent.rb | |
| +++ b/lib/nanite/agent.rb | |
| @@ -178,17 +178,21 @@ module Nanite | |
| def setup_traps | |
| ['INT', 'TERM'].each do |sig| | |
| - trap(sig) do | |
| + old = trap(sig) do |