README in posix_mq-0.1.0 vs README in posix_mq-0.2.0
- old
+ new
@@ -11,13 +11,13 @@
== Features
* Supports message notifications via signals.
-* Supports portable non-blocking operation. Under Linux 2.6.6+ only,
- POSIX_MQ objects may even be used with event notification mechanisms
- such as IO.select.
+* 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.
* Optional timeouts may be applied to send and receive operations.
* Thread-safe under Ruby 1.9, releases GVL before blocking operations.
@@ -39,9 +39,45 @@
http://bogomips.org/ruby_posix_mq/files/
Unpack it, and run "ruby setup.rb"
Otherwise, via RubyGems: gem install posix_mq
+
+== Usage
+
+The Linux mq_overview(7)
+{manpage}[http://kernel.org/doc/man-pages/online/pages/man7/mq_overview.7.html]
+provides a good overview of programming with POSIX message queues.
+
+Under FreeBSD, you must load the
+{mqueuefs(5)}[http://freebsd.org/cgi/man.cgi?query=mqueuefs]
+kernel module before attempting to use POSIX message queues:
+
+ kldload mqueuefs
+
+Our API matches the C api closely, see the RDoc for full API
+documentation. Here is an example of a process communicating
+with itself. In practice, processes that send will be different
+from processes that receive.
+
+ require 'posix_mq'
+ mq = POSIX_MQ.new("/foo", :rw)
+
+ # hello world
+ mq << "hello world"
+ puts mq.receive.first # => should print "hello world"
+
+ # non-blocking operation
+ mq.nonblock = true
+ begin
+ mq.receive
+ rescue Errno::EAGAIN
+ end
+
+ trap(:USR1) { puts mq.receive.first }
+ mq.notify = :USR1
+ mq.send "fire USR1 handler"
+ # "fire USR1 handler" should be printed now
== Development
You can get the latest source via git from the following locations: