Class: Qpid::Proton::Event::Collector
- Inherits:
-
Object
- Object
- Qpid::Proton::Event::Collector
- Defined in:
- lib/event/collector.rb
Overview
A Collector is used to register interest in events produced by one or more Connection objects.
Events
Instance Attribute Summary collapse
- #impl ⇒ Object readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Collector
constructor
Creates a new Collector.
-
#peek ⇒ Event?
Access the head event.
-
#pop ⇒ Boolean
Clear the head event.
-
#put(context, event_type) ⇒ Event?
Place a new event on the collector.
-
#release ⇒ Object
Releases the collector.
Constructor Details
#initialize ⇒ Collector
Creates a new Collector.
79 80 81 82 |
# File 'lib/event/collector.rb', line 79 def initialize @impl = Cproton.pn_collector ObjectSpace.define_finalizer(self, self.class.finalize!(@impl)) end |
Instance Attribute Details
#impl ⇒ Object (readonly)
75 76 77 |
# File 'lib/event/collector.rb', line 75 def impl @impl end |
Class Method Details
.finalize!(impl) ⇒ Object
85 86 87 88 89 |
# File 'lib/event/collector.rb', line 85 def self.finalize!(impl) proc { Cproton.pn_collector_free(impl) } end |
Instance Method Details
#peek ⇒ Event?
Access the head event.
This operation will continue to return the same event until it is cleared by using #pop. The pointer return by this operation will be valid until ::pn_collector_pop is invoked or #free is called, whichever happens sooner.
131 132 133 |
# File 'lib/event/collector.rb', line 131 def peek Event.wrap(Cproton.pn_collector_peek(@impl)) end |
#pop ⇒ Boolean
Clear the head event.
142 143 144 |
# File 'lib/event/collector.rb', line 142 def pop Cproton.pn_collector_pop(@impl) end |
#put(context, event_type) ⇒ Event?
Place a new event on the collector.
This operation will create a new event of the given type and context and return a new Event instance. In some cases an event of a given type can be elided. When this happens, this operation will return nil.
114 115 116 |
# File 'lib/event/collector.rb', line 114 def put(context, event_type) Cproton.pn_collector_put(@impl, Cproton.pn_rb2void(context), event_type.type_code) end |
#release ⇒ Object
Releases the collector.
Once in a released state, a collector will drain any internally queued events, shrink its memory footprint to a minimu, and discard any newly created events.
97 98 99 |
# File 'lib/event/collector.rb', line 97 def release Cproton.pn_collector_release(@impl) end |