You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by mc...@apache.org on 2015/06/08 20:13:49 UTC

[20/31] qpid-proton git commit: PROTON-781: Added the Timeout mixin to the Ruby APIs.

PROTON-781: Added the Timeout mixin to the Ruby APIs.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/5b72338a
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/5b72338a
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/5b72338a

Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 5b72338aee39379c56b799b6ec91aa2dbce3388f
Parents: 44f1312
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Mon Mar 2 15:42:20 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Mon Jun 8 13:57:52 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/ruby/lib/qpid_proton.rb  |  1 +
 proton-c/bindings/ruby/lib/util/timeout.rb | 50 +++++++++++++++++++++++++
 2 files changed, 51 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5b72338a/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 5b0d23f..0c84f20 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -40,6 +40,7 @@ require "util/wrapper"
 require "util/class_wrapper"
 require "util/engine"
 require "util/uuid"
+require "util/timeout"
 
 # Types
 require "types/strings"

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5b72338a/proton-c/bindings/ruby/lib/util/timeout.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/util/timeout.rb b/proton-c/bindings/ruby/lib/util/timeout.rb
new file mode 100644
index 0000000..f4647f5
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/util/timeout.rb
@@ -0,0 +1,50 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Util
+
+  # Provides methods for converting between milliseconds, seconds
+  # and timeout values.
+  #
+  # @private
+  module Timeout
+
+    def sec_to_millis(s)
+      return (s * 1000).to_int
+    end
+
+    def millis_to_sec(ms)
+      return (ms.to_f / 1000.0).to_int
+    end
+
+    def timeout_to_millis(s)
+      return Cproton::PN_MILLIS_MAX if s.nil?
+
+      return sec_to_millis(s)
+    end
+
+    def millis_to_timeout(ms)
+      return nil if ms == Cproton::PN_MILLIS_MAX
+
+      return millis_to_sec(ms)
+    end
+
+  end
+
+end


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org