PROTON-781: Added reactor support to the Ruby Event class.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/ebb14baf Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/ebb14baf Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/ebb14baf Branch: refs/heads/cjansen-cpp-client Commit: ebb14bafb2aedc816ad472d84e64489332f00c64 Parents: 02387ab Author: Darryl L. Pierce <[email protected]> Authored: Mon May 18 15:02:18 2015 -0400 Committer: Darryl L. Pierce <[email protected]> Committed: Thu Jun 18 16:28:44 2015 -0400 ---------------------------------------------------------------------- proton-c/bindings/ruby/lib/event/event.rb | 38 ++++++++++++++++++++------ 1 file changed, 30 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ebb14baf/proton-c/bindings/ruby/lib/event/event.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/lib/event/event.rb b/proton-c/bindings/ruby/lib/event/event.rb index dd5d869..e839f63 100644 --- a/proton-c/bindings/ruby/lib/event/event.rb +++ b/proton-c/bindings/ruby/lib/event/event.rb @@ -37,6 +37,13 @@ module Qpid::Proton # be generated. NONE = event_type(:PN_EVENT_NONE) + # A reactor has been started. + REACTOR_INIT = event_type(:PN_REACTOR_INIT) + # A reactor has no more events to process. + REACTOR_QUIESCED = event_type(:PN_REACTOR_QUIESCED) + # A reactor has been stopred. + REACTOR_FINAL = event_type(:PN_REACTOR_FINAL) + # A timer event has occurred. TIMER_TASK = event_type(:PN_TIMER_TASK) @@ -199,17 +206,32 @@ module Qpid::Proton # def dispatch(handler, type = nil) type = @type if type.nil? - #notify any and all attached handlers - if handler.respond_to?(:handlers?) && handler.handlers? - handler.handlers.each {|hndlr| self.dispatch(hndlr, type)} - end - if handler.respond_to?(type.method) - handler.__send__(type.method, self) - elsif handler.respond_to?(:on_unhandled) - handler.on_unhandled(self) + if handler.is_a?(Qpid::Proton::Handler::WrappedHandler) + Cproton.pn_handler_dispatch(handler.impl, @impl, type.number) + else + result = Qpid::Proton::Event.dispatch(handler, type.method, self) + if (result != "DELEGATED") && handler.respond_to?(:handlers) + handler.handlers.each do |hndlr| + self.dispatch(hndlr) + end + end end end + # Returns the reactor for this event. + # + # @return [Reactor, nil] The reactor. + # + def reactor + impl = Cproton.pn_event_reactor(@impl) + Qpid::Proton::Util::ClassWrapper::WRAPPERS["pn_reactor"].call(impl) + end + + def container + impl = Cproton.pn_event_reactor(@impl) + Qpid::Proton::Util::ClassWrapper::WRAPPERS["pn_reactor"].call(impl) + end + # Returns the transport for this event. # # @return [Transport, nil] The transport. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
