about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-01-07 09:28:57 +0000
committerEric Wong <normalperson@yhbt.net>2010-01-07 01:33:57 -0800
commit3700db51399e4949ed314ad0545d037b7762064e (patch)
tree39d37cc0942d31250ec088d19cea86cf5e2c31a5
parent40d61f55ac53e3cd2f229d0b032da03032e3d53d (diff)
downloadruby_posix_mq-3700db51399e4949ed314ad0545d037b7762064e.tar.gz
SIGEV_THREAD is not easy to implement, so many platforms
do not implement it.
-rw-r--r--README7
-rw-r--r--lib/posix_mq.rb8
-rw-r--r--test/test_posix_mq.rb4
3 files changed, 14 insertions, 5 deletions
diff --git a/README b/README
index 5be5478..a7d9e3d 100644
--- a/README
+++ b/README
@@ -11,13 +11,16 @@ network-aware message queue implementations.
 
 == Features
 
-* Supports message notifications via signals and block execution
-  in a separate thread.
+* Supports message notifications via signals on all platforms
 
 * Supports portable non-blocking operation.  Under Linux 2.6.6+ and
   FreeBSD 7.2+, POSIX_MQ objects may even be used with event
   notification mechanisms such as IO.select.
 
+* Supports notifications via block execution in a separate thread
+  on platforms that implement SIGEV_THREAD for mq_notify(3),
+  currently only GNU/Linux.
+
 * Optional timeouts may be applied to send and receive operations.
 
 * Thread-safe blocking operations under Ruby 1.9, releases GVL
diff --git a/lib/posix_mq.rb b/lib/posix_mq.rb
index 91f4140..8897050 100644
--- a/lib/posix_mq.rb
+++ b/lib/posix_mq.rb
@@ -37,6 +37,12 @@ class POSIX_MQ
   # first message and must be reset/reenabled for subsequent
   # notifications.  This block will execute in a separate Ruby
   # Thread (and thus will safely have the GVL by default).
+  #
+  # This method is only supported on platforms that implement
+  # SIGEV_THREAD functionality in mq_notify(3).  So far we only
+  # know of glibc + Linux supporting this.  Please let us
+  # know if your platform can support this functionality and
+  # are willing to test for us <ruby.posix.mq@librelist.com>
   def notify(&block)
     block.arity == 1 or
       raise ArgumentError, "arity of notify block must be 1"
@@ -58,7 +64,7 @@ class POSIX_MQ
     self.notify = w
     self.notify_thread = thr
     nil
-  end
+  end if RUBY_PLATFORM =~ /linux/
 
 end
 
diff --git a/test/test_posix_mq.rb b/test/test_posix_mq.rb
index 58ee6e5..1fa029b 100644
--- a/test/test_posix_mq.rb
+++ b/test/test_posix_mq.rb
@@ -249,7 +249,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
     assert_nothing_raised { @mq.notify { |mq| q << "hi" } }
     @mq << "bye"
     assert_equal "hi", q.pop
-  end
+  end if POSIX_MQ.respond_to?(:notify)
 
   def test_notify_thread
     q = Queue.new
@@ -262,5 +262,5 @@ class Test_POSIX_MQ < Test::Unit::TestCase
     assert x.instance_of?(Thread)
     assert Thread.current != x
     assert ! thr.alive?
-  end
+  end if POSIX_MQ.respond_to?(:notify)
 end