From: Mido Peace Date: 2010-02-03T17:49:29+09:00 Subject: Re: Ruby Threads From C Roger Pack wrote: > >> Do you you have an example of doing this from within C that you can >> point to? My C isn't at an expert level, and I've had some trouble >> finding an example that I can work with to do this sort of thing. > > Appears there's also an rb_thread_create, though I have no idea how to > use it. > > > http://betterlogic.com/roger/?p=2474&cpage=1#comment-3372 > > might work...the kicker though is that if you're looking for something > like > > rb_go_and_do_this_in_some_other_thread("stuff") > > Then I don't think using ruby's C API to start a thread will work--you > may need to run the ruby code in a separate C thread. > > GL! > -r Actually , I tried : rb_funcall3(rb_const_get(rb_cObject, rb_intern("Thread")), rb_intern("new"), 0, 0); But >> `initialize': must be called with a block (ThreadError) it seems like the Thread Class should always be called with a Block of instrcution to execute as we do with Ruby Code Thread.new{ do .. this .. ect } I found Some C Methods to deal with Ruby Thread : ... VALUE rb_thread_stop (void) VALUE rb_thread_wakeup (VALUE) VALUE rb_thread_run (VALUE) VALUE rb_thread_kill (VALUE) VALUE rb_thread_create (VALUE(*(ANYARGS), void *)) void rb_thread_interrupt (void) void rb_thread_trap_eval (VALUE, int) void rb_thread_signal_raise (char *) int rb_thread_select (ANYARGS) void rb_thread_wait_for (ANYARGS) VALUE rb_thread_current (void) VALUE rb_thread_main (void) ... http://ruby-doc.org/doxygen/1.8.4/group__ruby__eval.html But not yet sure that it really create and manage a Ruby Thread ( especially that this One should be always initialized with a block of instructions ) -- Posted via http://www.ruby-forum.com/.