21 messages in org.ruby-lang.ruby-talkRe: C Threads and Ruby
FromSent OnAttachments
Kroeger, Simon (ext)Jun 20, 2006 3:27 am 
Patrick HurleyJun 20, 2006 4:28 am 
Kroeger, Simon (ext)Jun 20, 2006 4:59 am 
Francis CianfroccaJun 20, 2006 5:13 am 
Patrick HurleyJun 20, 2006 9:39 am 
Paul BrannanJun 20, 2006 11:33 am 
Patrick HurleyJun 20, 2006 1:16 pm 
Francis CianfroccaJun 20, 2006 1:17 pm 
Francis CianfroccaJun 20, 2006 1:19 pm 
Simon KrögerJun 20, 2006 2:29 pm 
Joel VanderWerfJun 20, 2006 2:35 pm 
Francis CianfroccaJun 20, 2006 2:39 pm 
Bill KellyJun 20, 2006 2:42 pm 
Simon KrögerJun 20, 2006 2:49 pm 
Francis CianfroccaJun 20, 2006 3:26 pm 
Francis CianfroccaJun 20, 2006 3:34 pm 
Bill KellyJun 20, 2006 4:08 pm 
Francis CianfroccaJun 20, 2006 5:07 pm 
Kroeger, Simon (ext)Jun 21, 2006 2:53 am 
Francis CianfroccaJun 21, 2006 3:15 am 
Paul BrannanJun 22, 2006 8:21 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: C Threads and RubyActions...
From:Kroeger, Simon (ext) (simo@siemens.com)
Date:Jun 20, 2006 4:59:18 am
List:org.ruby-lang.ruby-talk

From: Patrick Hurley [mailto:phur@gmail.com] Sent: Tuesday, June 20, 2006 1:29 PM

It depends what you are trying to do. I just worked up a patch to win32-service, that does this by creating a ruby thread in the C extension that polls against a simple integer guarded by a mutex -- when an event occurs it is signaled there and the correct call back is spun off in yet another ruby thread. I was worried this would be "expensive", but the rb_thread_polling method, worked like a charm.

Yeah, I'm doing something simmilar with rb_thread_wait_for instead of rb_thread_polling. rb_thread_polling does sleep for 6ms. While this may be acceptable it is not exactly what I was looking for. (I'm sleeping for only 1ms and there is no noticeable cpu requirement)

Perhaps my problem is: I just hate polling.

This idea could be easily extended to allow for an event queue that was filled by a native C thread and processed by a ruby thread. Note that calling any rb_XXXX from anything other than the "ruby thread" is a really bad idea.

pth

thanks anyway,

Simon