module Mixpanel::Async

Constants

WORKER_MUTEX

Public Instance Methods

dispose_worker(w) click to toggle source
# File lib/mixpanel/async.rb, line 10
def dispose_worker(w)
  WORKER_MUTEX.synchronize do
    if(@worker == w)
      @worker = nil
      w.close
    end
  end
end
worker() click to toggle source
# File lib/mixpanel/async.rb, line 4
def worker
  WORKER_MUTEX.synchronize do
    @worker || (@worker = IO.popen(self.cmd, 'w'))
  end
end

Protected Instance Methods

cmd() click to toggle source
# File lib/mixpanel/async.rb, line 21
def cmd
  @cmd || begin
    require 'escape'
    require 'rbconfig'
    interpreter = File.join(*RbConfig::CONFIG.values_at("bindir", "ruby_install_name")) + RbConfig::CONFIG["EXEEXT"]
    subprocess = File.join(File.dirname(__FILE__), 'subprocess.rb')
    @cmd = Escape.shell_command([interpreter, subprocess])
  end
end