From bbf6a947e81ca0675ef21d15cece57acd2771102 Mon Sep 17 00:00:00 2001 From: Brent Roman Date: Fri, 13 Feb 2009 21:00:44 -0800 Subject: [PATCH] MBARI 1 --- eval.c | 24 ++++++++++++++++++++++++ version.h | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/eval.c b/eval.c index 130dcaea3f..26c095a607 100644 --- a/eval.c +++ b/eval.c @@ -13145,6 +13145,29 @@ rb_cont_call(argc, argv, cont) } +/* + * call-seq: + * cont.thread + * + * Returns the thread on which this continuation can be called + * (or nil if that thread has died) + * + * t = Thread.new {callcc{|c| $x=c}; sleep 5} + * sleep 1 + * $x.thread #=> t + * sleep 10 + * $x.thread #=> nil + */ +static VALUE +rb_cont_thread(cont) + VALUE cont; +{ + rb_thread_t th = THREAD_DATA(cont); + cc_purge(th); + return th->thread; +} + + struct thgroup { int enclosed; VALUE group; @@ -13498,6 +13521,7 @@ Init_Thread() rb_undef_method(CLASS_OF(rb_cCont), "new"); rb_define_method(rb_cCont, "call", rb_cont_call, -1); rb_define_method(rb_cCont, "[]", rb_cont_call, -1); + rb_define_method(rb_cCont, "thread", rb_cont_thread, 0); rb_define_global_function("callcc", rb_callcc, 0); rb_global_variable(&cont_protect); diff --git a/version.h b/version.h index 87bba5e7b6..d7cd21c5df 100644 --- a/version.h +++ b/version.h @@ -25,7 +25,7 @@ RUBY_EXTERN const char *ruby_copyright; #define RUBY_BIRTH_MONTH 2 #define RUBY_BIRTH_DAY 24 -#define RUBY_RELEASE_STR "MBARI 1- on patchlevel" +#define RUBY_RELEASE_STR "MBARI 1 on patchlevel" #define RUBY_RELEASE_NUM RUBY_PATCHLEVEL