Date | Commit message (Collapse) |
|
This release adds a few new API methods, fixes MRI 1.8.6
support. We should now have full feature parity with
underlying POSIX message queue C API.
* POSIX_MQ#notify(&block)
RDoc: http://bogomips.org/ruby_posix_mq/POSIX_MQ.html#M000001
This is only supported on platforms that implement
SIGEV_THREAD with mq_notify(3) (tested with glibc + Linux).
Other platforms will have to continue to rely on signal
notifications via POSIX#notify=signal, or IO notifications
in FreeBSD (and Linux).
* POSIX_MQ#shift([buffer [,timeout]])
Shorthand for the common "POSIX_MQ#receive.first"
when you do not care for priority of the received message.
Rev, EventMachine and Reactor support are planned for
Linux, FreeBSD and possibly any other platforms where POSIX
message queues are implemented with a file descriptor.
|
|
It's Rubinius-specific and we use rb_str_resize
there anyways...
|
|
It's not needed since the native thread will retry in the
unlikely case of EINTR/EAGAIN. And writing one byte to a pipe
that's guaranteed by POSIX to be at least 512 bytes is highly
unlikely.
It's also bad because F_SETFL takes the big kernel lock under
Linux (and possibly other systems), and doing it unnecessarily
is a waste of system cycles.
|
|
Most used open modes are well under INT_MAX, however
|
|
This acts like POSIX_MQ#receive but only returns the message
without the priority.
|
|
SIGEV_THREAD is not easy to implement, so many platforms
do not implement it.
|
|
This is implementation uses both a short-lived POSIX thread and
a pre-spawned Ruby Thread in a manner that works properly under
both Ruby 1.8 (green threads) and 1.9 (where Ruby Threads are
POSIX threads).
The short-lived POSIX thread will write a single "\0" byte to
a pipe the Ruby Thread waits on. This operation is atomic
on all platforms. Once the Ruby Thread is woken up from the
pipe, it will execute th block given to it.
This dual-thread implementation is inspired by the way glibc
implements mq_notify(3) + SIGEV_THREAD under Linux where the
kernel itself cannot directly spawn POSIX threads.
|
|
The POSIX manpages specify the return values of all
mq_* functions besides mq_open(3) to be "int", not "mqd_t".
|
|
Shouldn't affect most people since they should just
take code from git...
|
|
This release fixes notification (un)registration and should be
fully-supported on modern FreeBSD (7.2+) releases.
POSIX_MQ#notify=nil correctly unregister notification requests.
POSIX_MQ#notify=false now provids the no-op SIGEV_NONE
functionality. Under FreeBSD, using IO.select on POSIX_MQ
objects is now possible as it has always been under Linux.
|
|
FreeBSD implements an __mq_oshandle(mqd_t mqd) function
to convert mqd_t to integer file descriptors.
|
|
FreeBSD seems to need some files explicitly included.
|
|
|
|
"mq.notify = false" also works now, doing what
"mq.notify = nil" used to do (using SIGEV_NONE).
I was confused by SIGEV_NONE usage vs using a NULL pointer for
the notification passed mq_notify(3). SIGEV_NONE does not
actually unregister, it registers a no-op notification which
prevents other processes from taking us.
This also fixes the test case to pass under both Linux and
FreeBSD.
|
|
|