about summary refs log tree commit homepage
path: root/lib/rainbows/event_machine_defer.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-05-04 13:41:55 -0700
committerEric Wong <normalperson@yhbt.net>2010-05-04 13:41:55 -0700
commite8cedc2584d23a8ab214ff96a973dc37344c2796 (patch)
treee5fa8a9f1f033f4ae407280f7db457f49d003666 /lib/rainbows/event_machine_defer.rb
parente61f0f4f901848e59b7b756224c765afde217a71 (diff)
downloadrainbows-e8cedc2584d23a8ab214ff96a973dc37344c2796.tar.gz
Since we have conditional deferred execution in the regular
EventMachine concurrency model, we can drop this one.

This concurrency model never fully worked due to lack of
graceful shut downs, and was never promoted nor supported, either.
Diffstat (limited to 'lib/rainbows/event_machine_defer.rb')
-rw-r--r--lib/rainbows/event_machine_defer.rb59
1 files changed, 0 insertions, 59 deletions
diff --git a/lib/rainbows/event_machine_defer.rb b/lib/rainbows/event_machine_defer.rb
deleted file mode 100644
index 97518c5..0000000
--- a/lib/rainbows/event_machine_defer.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-# -*- encoding: binary -*-
-# :stopdoc:
-# FIXME: fails many tests, experimental
-require 'rainbows/event_machine'
-
-module Rainbows
-
-  # This is currently highly experimental
-  module EventMachineDefer
-    include Rainbows::EventMachine
-
-    class Client < Rainbows::EventMachine::Client
-      undef_method :app_call
-
-      def defer_op
-        @env[RACK_INPUT] = @input
-        @env[REMOTE_ADDR] = @remote_addr
-        @env[ASYNC_CALLBACK] = method(:response_write)
-        catch(:async) { APP.call(@env.update(RACK_DEFAULTS)) }
-        rescue => e
-          handle_error(e)
-          nil
-      end
-
-      def defer_callback(response)
-        # too tricky to support pipelining with :async since the
-        # second (pipelined) request could be a stuck behind a
-        # long-running async response
-        (response.nil? || -1 == response.first) and return @state = :close
-
-        resume
-
-        alive = @hp.keepalive? && G.alive
-        out = [ alive ? CONN_ALIVE : CONN_CLOSE ] if @hp.headers?
-        response_write(response, out, alive)
-        if alive
-          @env.clear
-          @hp.reset
-          @state = :headers
-          if @hp.headers(@env, @buf)
-            EM.next_tick(method(:app_call))
-          else
-            set_comm_inactivity_timeout(G.kato)
-          end
-        else
-          quit
-        end
-      end
-
-      def app_call
-        pause
-        set_comm_inactivity_timeout(0)
-        # defer_callback(defer_op)
-        EM.defer(method(:defer_op), method(:defer_callback))
-      end
-    end
-
-  end
-end