From 40d61f55ac53e3cd2f229d0b032da03032e3d53d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 7 Jan 2010 00:37:57 -0800 Subject: POSIX_MQ#notify block execution on message received 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. --- ext/posix_mq/extconf.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'ext/posix_mq/extconf.rb') diff --git a/ext/posix_mq/extconf.rb b/ext/posix_mq/extconf.rb index b9e8963..b473c13 100644 --- a/ext/posix_mq/extconf.rb +++ b/ext/posix_mq/extconf.rb @@ -4,9 +4,11 @@ have_header("sys/select.h") have_header("signal.h") have_header("mqueue.h") or abort "mqueue.h header missing" have_func("__mq_oshandle") +have_header("pthread.h") have_func("rb_str_set_len") have_func("rb_struct_alloc_noinit") have_func('rb_thread_blocking_region') have_library("rt") +have_library("pthread") dir_config("posix_mq") create_makefile("posix_mq_ext") -- cgit v1.2.3-24-ge0c7