summary refs log tree commit homepage
tag namev0.8.0pre (69be1297f927f6f0985a1cfb1f4b681b9cf0d5ec)
tag date2011-02-27 11:13:02 +0000
tagged byEric Wong <normalperson@yhbt.net>
tagged objectcommit 3308466144...
posix_mq 0.8.0pre - kinder, gentler and less exceptional
This adds trysend, tryreceive, and tryshift interfaces to avoid
exceptions on common EAGAIN errors for non-blocking users.  EAGAIN
during non-blocking messages is common when there are multiple
readers/writer threads/processes working on the same queue.

trysend is like send, except it returns true for success and false for
EAGAIN.  send (still) returns nil, which I now consider a mistake but
won't change until post-1.0...

tryreceive and tryshift are like receive and shift respectively,
but they return nil for EAGAIN and the same return values
for their non-shift variants.

None of these methods call mq_setattr() beforehand to set the
non-blocking flag, it assumes the user set it once before they were ever
called and never changes it.  Checking/setting the non-blocking flag
every time is needless overhead and still subject to race conditions if
multiple processes/queues keep flipping flag on the same queue
descriptor.

These interfaces are not yet final, feedback is appreciated
at ruby.posix.mq@librelist.org.