From: hemant Date: 2007-12-07T19:18:55+09:00 Subject: Re: How to have fine grain control over GL in C extensions Hi, On Dec 7, 2007 3:40 PM, SASADA Koichi wrote: > Hi, > > hemant wrote: > > Well.. first I am not able to handle interupts and signals. I tried > > CHECK_INTS and RUBY_VM_CHECK_INTS both and it throws undefined symbol > > error. > > OK. I'll add a C API such as rb_thread_interrupted(void). But you > don't need this API on your example. But lots of C extension use CHECK_INTS i suppose? Not needed in my trivial example, but there are extensions out there making use of CHECK_INTS. > > > Also, I do not think, both functions are getting executed > > concurrently. Is there anything else I need to do? > > 2 comments: > > 1. Ruby is already concurrent thread. You may mean "parallel". > So Ruby's thread is "ConcurrentThread". > > 2. It seems run in parallel. Why do you think so? > Yeah..sorry i confused concurrency with parallelism. I meant parallelism in truth. > > Last and final question is, how am i supposed to interupt > > count_to_100000 method from stop_thr1 ? > > example: > > static void count_to_10000(void* data){ > int i = 0; > for( i = 0; i < 10000; i++ ) { > if ((*(VALUE *)data) == Qtrue) { > break; > } > printf("Currently Counting from thr 1: %d\n",i); > } > } > > static void stop_thr1(void* data) { > printf("Calling thread1 break method\n"); > *((VALUE *)data) = Qtrue; > } > > static VALUE rb_concurrent_thread_method(VALUE self) > { > VALUE interrupt_flag; > rb_thread_blocking_region(count_to_10000, &interrupt_flag, > stop_thr1, &interrupt_flag); > } > > > -- > // SASADA Koichi at atdot dot net > > Thanks for the explanation -- Let them talk of their oriental summer climes of everlasting conservatories; give me the privilege of making my own summer with my own coals. http://gnufied.org