posix_mq RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [ANN] posix_mq 2.3.0 - POSIX Message Queues for Ruby
@ 2016-02-02 23:34  7% Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2016-02-02 23:34 UTC (permalink / raw)
  To: ruby-talk, ruby-posix-mq

POSIX message queues allow local processes to exchange data in the form
of messages.  This API is distinct from that provided by System V
message queues, but provides similar functionality.

* http://bogomips.org/ruby_posix_mq/
* mailto:ruby-posix-mq@bogomips.org
* git clone git://bogomips.org/ruby_posix_mq.git
* Atom feed: http://bogomips.org/ruby_posix_mq/NEWS.atom.xml
* archives: http://bogomips.org/ruby-posix-mq/
  nntp://news.public-inbox.org/inbox.comp.lang.ruby.posix-mq
* gem install -v 2.3.0 posix_mq

Changes:

    Ruby posix_mq 2.3.0 - updates for Ruby 2.3+

    This release updates our POSIX_MQ#close to match the idempotent
    IO#close behavior under Ruby 2.3 and later.  Previous Ruby versions
    continue to be supported, but POSIX_MQ#close remains non-idempotent
    when built against old Ruby versions.

    4 changes since v2.2.0:

          enable frozen_string_literal for Ruby 2.3+
          support idempotent POSIX_MQ#close
          README: remove cgit and ssoma references
          build: use '--local' domain for dev gem install

Have fun!

^ permalink raw reply	[relevance 7%]

* [PATCH] enable frozen_string_literal for Ruby 2.3+
@ 2016-02-02 20:14  5% Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2016-02-02 20:14 UTC (permalink / raw)
  To: ruby-posix-mq; +Cc: Eric Wong

No changes for older Rubies, but this reduces garbage under 2.3
---
 bin/posix-mq-rb       |  3 ++-
 lib/posix_mq.rb       |  3 +--
 test/test_posix_mq.rb | 15 ++++++++-------
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/bin/posix-mq-rb b/bin/posix-mq-rb
index 8c77aea..45efb7b 100755
--- a/bin/posix-mq-rb
+++ b/bin/posix-mq-rb
@@ -1,5 +1,6 @@
 #!/usr/bin/env ruby
 # -*- encoding: binary -*-
+# -*- frozen_string_literal: true -*-
 $stderr.sync = $stdout.sync = true
 $stdout.binmode
 $stderr.binmode
@@ -100,7 +101,7 @@ begin
   when :create
     exit
   when :receive
-    buf, prio = mq.receive("", timeout)
+    buf, prio = mq.receive(nil, timeout)
     $stderr.write("priority=#{prio}\n") if priority
     $stdout.write(buf)
   when :send
diff --git a/lib/posix_mq.rb b/lib/posix_mq.rb
index 5424667..2dc6dcf 100644
--- a/lib/posix_mq.rb
+++ b/lib/posix_mq.rb
@@ -1,4 +1,4 @@
-# -*- encoding: binary -*-
+# -*- frozen_string_literal: true -*-
 #
 # This class represents an POSIX message queue descriptor (mqd_t)
 # object.  It matches the C API for POSIX messages queues closely.
@@ -79,7 +79,6 @@ class POSIX_MQ
   # All send/receive operations are atomic and only one
   # native thread may be notified at a time
   alias clone dup
-
 end
 
 require 'posix_mq_ext'
diff --git a/test/test_posix_mq.rb b/test/test_posix_mq.rb
index 35967e8..d726d36 100644
--- a/test/test_posix_mq.rb
+++ b/test/test_posix_mq.rb
@@ -1,4 +1,5 @@
 # -*- encoding: binary -*-
+# frozen_string_literal: true
 require 'test/unit'
 require 'thread'
 require 'fcntl'
@@ -68,7 +69,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
     @mq = POSIX_MQ.new(@path, :rw)
     assert ! @mq.nonblock?
     t0 = Time.now
-    maybe_timeout { @mq.receive "", interval } or return
+    maybe_timeout { @mq.receive nil, interval } or return
     elapsed = Time.now - t0
     assert_operator elapsed, :>, interval, elapsed.inspect
     assert_operator elapsed, :<, 0.04, elapsed.inspect
@@ -82,7 +83,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
     @mq = POSIX_MQ.new(@path, :rw)
     assert ! @mq.nonblock?
     t0 = Time.now
-    maybe_timeout { @mq.receive "", interval } or return
+    maybe_timeout { @mq.receive nil, interval } or return
     elapsed = Time.now - t0
     assert_operator elapsed, :>=, 0.01, elapsed.inspect
     assert_operator elapsed, :<=, 0.04, elapsed.inspect
@@ -93,7 +94,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
     @mq = POSIX_MQ.new(@path, :rw)
     assert ! @mq.nonblock?
     t0 = Time.now
-    maybe_timeout { @mq.receive "", interval } or return
+    maybe_timeout { @mq.receive nil, interval } or return
     elapsed = Time.now - t0
     assert elapsed >= interval, elapsed.inspect
     assert elapsed < 1.10, elapsed.inspect
@@ -159,7 +160,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
   end
 
   def test_name
-    path = "" << @path.dup
+    path = @path.dup
     path.freeze
     @mq = POSIX_MQ.new @path, IO::CREAT|IO::WRONLY, 0666
     assert_equal path, @mq.name
@@ -192,7 +193,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
   end
 
   def test_shift_buf
-    buf = ""
+    buf = "".dup
     @mq = POSIX_MQ.new @path, IO::CREAT|IO::RDWR, 0666
     @mq << "hello"
     assert_equal "hello", @mq.shift(buf)
@@ -206,7 +207,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
   end
 
   def test_send_receive_buf
-    buf = ""
+    buf = "".dup
     @mq = POSIX_MQ.new @path, IO::CREAT|IO::RDWR, 0666
     assert_equal true, @mq.send("hello", 0)
     assert_equal [ "hello", 0 ], @mq.receive(buf)
@@ -236,7 +237,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
   end if POSIX_MQ.method_defined?(:to_io)
 
   def test_for_fd
-    buf = ""
+    buf = "".dup
     @mq = POSIX_MQ.new @path, IO::CREAT|IO::RDWR, 0666
     @alt = POSIX_MQ.for_fd(@mq.to_io.to_i)
     assert_equal true, @mq.send("hello", 0)
-- 
EW


^ permalink raw reply related	[relevance 5%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-02-02 20:14  5% [PATCH] enable frozen_string_literal for Ruby 2.3+ Eric Wong
2016-02-02 23:34  7% [ANN] posix_mq 2.3.0 - POSIX Message Queues for Ruby Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/ruby_posix_mq.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).