Class: Qpid::Proton::Selectable

Inherits:
Object
  • Object
show all
Includes:
Filters
Defined in:
lib/qpid_proton/selectable.rb

Overview

Selectable enables accessing the underlying file descriptors for Messenger.

Instance Method Summary collapse

Methods included from Filters

included

Constructor Details

#initialize(messenger, impl) ⇒ Selectable

:nodoc:



35
36
37
38
39
40
# File 'lib/qpid_proton/selectable.rb', line 35

def initialize(messenger, impl) # :nodoc:
  @messenger = messenger
  @impl = impl
  @io = nil
  @freed = false
end

Instance Method Details

#capacityObject

The number of bytes the selectable is capable of consuming.



56
57
58
# File 'lib/qpid_proton/selectable.rb', line 56

def capacity
  Cproton.pn_selectable_capacity(@impl)
end

#deadlineObject

The future expiry time at which control will be returned to the selectable.



69
70
71
72
# File 'lib/qpid_proton/selectable.rb', line 69

def deadline
  tstamp = Cproton.pn_selectable_deadline(@impl)
  tstamp.nil? ? nil : tstamp / 1000
end

#expired?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/qpid_proton/selectable.rb', line 82

def expired?
  Cproton.pn_selectable_expired(@impl)
end

#filenoObject

Returns the underlying file descriptor.

This can be used in conjunction with the IO class.



46
47
48
# File 'lib/qpid_proton/selectable.rb', line 46

def fileno
  Cproton.pn_selectable_fd(@impl)
end

#freeObject



103
104
105
106
107
108
109
110
# File 'lib/qpid_proton/selectable.rb', line 103

def free
  return if @freed
  @freed = true
  @messenger.unregister_selectable(fileno)
  @io.close unless @io.nil?
  Cproton.pn_selectable_free(@impl)
  @impl = nil
end

#freed?Boolean

:nodoc:

Returns:

  • (Boolean)


112
113
114
# File 'lib/qpid_proton/selectable.rb', line 112

def freed? # :nodoc:
  @freed
end

#pendingObject

The number of bytes waiting to be written to the file descriptor.



62
63
64
# File 'lib/qpid_proton/selectable.rb', line 62

def pending
  Cproton.pn_selectable_pending(@impl)
end

#readableObject



74
75
76
# File 'lib/qpid_proton/selectable.rb', line 74

def readable
  Cproton.pn_selectable_readable(@impl)
end

#registered=(registered) ⇒ Object



86
87
88
# File 'lib/qpid_proton/selectable.rb', line 86

def registered=(registered)
  Cproton.pn_selectable_set_registered(@impl, registered)
end

#registered?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/qpid_proton/selectable.rb', line 90

def registered?
  Cproton.pn_selectable_is_registered(@impl)
end

#terminal?Boolean

Returns:

  • (Boolean)


94
95
96
97
# File 'lib/qpid_proton/selectable.rb', line 94

def terminal?
  return true if @impl.nil?
  Cproton.pn_selectable_is_terminal(@impl)
end

#to_ioObject



50
51
52
# File 'lib/qpid_proton/selectable.rb', line 50

def to_io
  @io ||= IO.new(fileno)
end

#to_sObject



99
100
101
# File 'lib/qpid_proton/selectable.rb', line 99

def to_s
  "fileno=#{self.fileno} registered=#{self.registered?} terminal=#{self.terminal?}"
end

#writableObject



78
79
80
# File 'lib/qpid_proton/selectable.rb', line 78

def writable
  Cproton.pn_selectable_writable(@impl)
end