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/07ddaaf3 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/07ddaaf3 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/07ddaaf3 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 07ddaaf309e36f458f2e4dca6c388902d3c6a865 Parents: 83e923b Author: Darryl L. Pierce <mcpie...@gmail.com> Authored: Mon May 18 15:02:18 2015 -0400 Committer: Darryl L. Pierce <mcpie...@gmail.com> Committed: Thu Jun 18 09:27:20 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/07ddaaf3/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: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org