Module: Yahns::ClientExpireGeneric

Defined in:
lib/yahns/client_expire_generic.rb

Overview

Copyright © 2013-2016 all contributors <[email protected]> License: GPL-3.0+ (www.gnu.org/licenses/gpl-3.0.txt) frozen_string_literal: true

Instance Method Summary collapse

Instance Method Details

#__timestampObject

:nodoc:



5
6
7
# File 'lib/yahns/client_expire_generic.rb', line 5

def __timestamp
  Yahns.now
end

#kgio_tryread(*args) ⇒ Object



32
33
34
35
# File 'lib/yahns/client_expire_generic.rb', line 32

def kgio_tryread(*args)
  @last_io_at = __timestamp
  super
end

#kgio_trywrite(*args) ⇒ Object



27
28
29
30
# File 'lib/yahns/client_expire_generic.rb', line 27

def kgio_trywrite(*args)
  @last_io_at = __timestamp
  super
end

#trysendfile(*args) ⇒ Object



37
38
39
40
# File 'lib/yahns/client_expire_generic.rb', line 37

def trysendfile(*args)
  @last_io_at = __timestamp
  super
end

#yahns_expire(timeout) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/yahns/client_expire_generic.rb', line 14

def yahns_expire(timeout)
  return 0 if closed?
  if (__timestamp - @last_io_at) > timeout
    shutdown
    1
  else
    0
  end
# shutdown may race with the shutdown in http_response_done
rescue
  0
end

#yahns_initObject



9
10
11
12
# File 'lib/yahns/client_expire_generic.rb', line 9

def yahns_init
  super # Yahns::HttpClient#yahns_init
  @last_io_at = 0
end