diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-01-02 02:33:23 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-01-02 03:01:36 -0800 |
commit | 522d4d1472c216bd95a16ca5b118bc14693aad64 (patch) | |
tree | f8fd62c3dd562117edc71e2488542532e9db4cd5 /lib/posix_mq.rb | |
download | ruby_posix_mq-522d4d1472c216bd95a16ca5b118bc14693aad64.tar.gz |
Diffstat (limited to 'lib/posix_mq.rb')
-rw-r--r-- | lib/posix_mq.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/posix_mq.rb b/lib/posix_mq.rb new file mode 100644 index 0000000..a2a85ee --- /dev/null +++ b/lib/posix_mq.rb @@ -0,0 +1,34 @@ +# -*- encoding: binary -*- +class POSIX_MQ + + # version of POSIX_MQ, currently 0.1.0 + VERSION = '0.1.0' + + # An analogous Struct to "struct mq_attr" in C. + # This may be used in arguments for POSIX_MQ.new and + # POSIX_MQ#attr=. POSIX_MQ#attr returns an instance + # of this class. + # + # See the mq_getattr(3) manpage for more information on the values. + Attr = Struct.new(:flags, :maxmsg, :msgsize, :curmsgs) + + class << self + + # Opens a POSIX message queue and performs operations on the + # given block, closing the message queue at exit. + # All all arguments are passed to POSIX_MQ.new. + def open(*args) + mq = new(*args) + block_given? or return mq + begin + yield mq + ensure + mq.close unless mq.closed? + end + end + + end + +end + +require 'posix_mq_ext' |