about summary refs log tree commit homepage
path: root/lib/kgio/autopush.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-12-15 22:53:48 +0000
committerEric Wong <e@80x24.org>2016-12-15 23:51:08 +0000
commit333347c3ae54c8d605c673fcd11ff8dcb2ea4c38 (patch)
tree0663faa01cb9f84457a1b55ab52867ed986dd64c /lib/kgio/autopush.rb
parent64dc570f4b99f68b5ed792b36e7e8abc3df74927 (diff)
downloadkgio-333347c3ae54c8d605c673fcd11ff8dcb2ea4c38.tar.gz
The regression for existing users was unnacceptable and
completely poor judgement on my part.  This change brings
us back to potentially not-future-compatible code which
will impose maintenance burdens on us in the face of
future Ruby changes.

But TODAY, it is the most performant option for folks who
need to use autopush.

Revert "resurrect Kgio.autopush support in pure Ruby"
and "remove autopush support and make it a no-op"

This reverts commits 64dc570f4b99f68b5ed792b36e7e8abc3df74927
and 4347980fa66115425fa8b765353c8b1bfe5dec24.
Diffstat (limited to 'lib/kgio/autopush.rb')
-rw-r--r--lib/kgio/autopush.rb68
1 files changed, 0 insertions, 68 deletions
diff --git a/lib/kgio/autopush.rb b/lib/kgio/autopush.rb
deleted file mode 100644
index fb33f11..0000000
--- a/lib/kgio/autopush.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-# Copyright (C) 2015 all contributors <kgio-public@bogomips.org>
-# License: LGPLv2.1 or later (https://www.gnu.org/licenses/lgpl-2.1.txt)
-
-require 'socket'
-require 'thread'
-
-# using this code is not recommended, for backwards compatibility only
-module Kgio::Autopush # :nodoc:
-  class SyncArray # :nodoc:
-    def initialize # :nodoc:
-      @map = []
-      @lock = Mutex.new
-    end
-
-    def []=(key, val) # :nodoc:
-      @lock.synchronize { @map[key] = val }
-    end
-
-    def [](key) # :nodoc:
-      @lock.synchronize { @map[key] }
-    end
-  end
-
-  FDMAP = SyncArray.new # :nodoc:
-  APState = Struct.new(:obj, :ap_state) # :nodoc:
-
-  # Not using pre-defined socket constants for 1.8 compatibility
-  if RUBY_PLATFORM.include?('linux')
-    NOPUSH = 3 # :nodoc:
-  elsif RUBY_PLATFORM.include?('freebsd')
-    NOPUSH = 4 # :nodoc:
-  end
-
-  def kgio_autopush? # :nodoc:
-    return false unless Kgio.autopush?
-    state = FDMAP[fileno]
-    state && state.obj == self && state.ap_state != :ignore
-  end
-
-  def kgio_autopush=(bool) # :nodoc:
-    if bool
-      state = FDMAP[fileno] ||= APState.new
-      state.ap_state = :writer
-      state.obj = self
-    end
-    bool
-  end
-
-private
-  def kgio_push_pending # :nodoc:
-    Kgio.autopush or return
-    state = FDMAP[fileno] or return
-    state.obj == self and state.ap_state = :written
-  end
-
-  def kgio_push_pending_data # :nodoc:
-    Kgio.autopush or return
-    state = FDMAP[fileno] or return
-    state.obj == self && state.ap_state == :written or return
-    setsockopt(Socket::IPPROTO_TCP, NOPUSH, 0)
-    setsockopt(Socket::IPPROTO_TCP, NOPUSH, 1)
-    state.ap_state = :writer
-  end
-end
-require 'kgio/autopush/sock_rw'
-require 'kgio/autopush/acceptor'
-Kgio::TCPSocket.__send__(:include, Kgio::Autopush::SockRW) # :nodoc:
-Kgio::Socket.__send__(:include, Kgio::Autopush::SockRW) # :nodoc: