Class: Qpid::Proton::Selectable
- Inherits:
-
Object
- Object
- Qpid::Proton::Selectable
- Includes:
- Filters
- Defined in:
- lib/qpid_proton/selectable.rb
Overview
Selectable enables accessing the underlying file descriptors for Messenger.
Instance Method Summary collapse
-
#capacity ⇒ Object
The number of bytes the selectable is capable of consuming.
-
#deadline ⇒ Object
The future expiry time at which control will be returned to the selectable.
- #expired? ⇒ Boolean
-
#fileno ⇒ Object
Returns the underlying file descriptor.
- #free ⇒ Object
-
#freed? ⇒ Boolean
:nodoc:.
-
#initialize(messenger, impl) ⇒ Selectable
constructor
:nodoc:.
-
#pending ⇒ Object
The number of bytes waiting to be written to the file descriptor.
- #readable ⇒ Object
- #registered=(registered) ⇒ Object
- #registered? ⇒ Boolean
- #terminal? ⇒ Boolean
- #to_io ⇒ Object
- #to_s ⇒ Object
- #writable ⇒ Object
Methods included from Filters
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
#capacity ⇒ Object
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 |
#deadline ⇒ Object
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
82 83 84 |
# File 'lib/qpid_proton/selectable.rb', line 82 def expired? Cproton.pn_selectable_expired(@impl) end |
#fileno ⇒ Object
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 |
#free ⇒ Object
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:
112 113 114 |
# File 'lib/qpid_proton/selectable.rb', line 112 def freed? # :nodoc: @freed end |
#pending ⇒ Object
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 |
#readable ⇒ Object
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
90 91 92 |
# File 'lib/qpid_proton/selectable.rb', line 90 def registered? Cproton.pn_selectable_is_registered(@impl) end |
#terminal? ⇒ 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_io ⇒ Object
50 51 52 |
# File 'lib/qpid_proton/selectable.rb', line 50 def to_io @io ||= IO.new(fileno) end |
#to_s ⇒ Object
99 100 101 |
# File 'lib/qpid_proton/selectable.rb', line 99 def to_s "fileno=#{self.fileno} registered=#{self.registered?} terminal=#{self.terminal?}" end |
#writable ⇒ Object
78 79 80 |
# File 'lib/qpid_proton/selectable.rb', line 78 def writable Cproton.pn_selectable_writable(@impl) end |