Skip to content
Browse files

testing thread cancelability is all loops wasn't a bright idea

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@2396 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
1 parent 62c8572 commit 10ef9b1de9fe290d3f6c8de2c91f18b2e7bb1618 Laurent Sansonetti committed Aug 27, 2009
Showing with 7 additions and 1 deletion.
  1. +2 −1 vm.h
  2. +5 −0 vm_eval.c
View
3 vm.h
@@ -407,10 +407,11 @@ VALUE rb_vm_current_exception(void);
void rb_vm_set_current_exception(VALUE exception);
VALUE rb_vm_backtrace(int level);
+#define TEST_THREAD_CANCEL() (pthread_testcancel())
+
VALUE rb_vm_pop_broken_value(void);
#define RETURN_IF_BROKEN() \
do { \
- pthread_testcancel(); \
VALUE __v = rb_vm_pop_broken_value(); \
if (__v != Qundef) { \
return __v; \
View
5 vm_eval.c
@@ -248,9 +248,14 @@ rb_yield_splat(VALUE values)
static VALUE
loop_i(void)
{
+ int count = 0;
for (;;) {
rb_yield(Qundef);
RETURN_IF_BROKEN();
+ if (++count < 100) {
+ TEST_THREAD_CANCEL();
+ count = 0;
+ }
}
return Qnil;
}

0 comments on commit 10ef9b1

Please sign in to comment.
Something went wrong with that request. Please try again.