Permalink
Browse files

MBARI 1

  • Loading branch information...
1 parent cba16a2 commit bbf6a947e81ca0675ef21d15cece57acd2771102 @brentr committed Feb 14, 2009
Showing with 25 additions and 1 deletion.
  1. +24 −0 eval.c
  2. +1 −1 version.h
View
24 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);
View
@@ -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

0 comments on commit bbf6a94

Please sign in to comment.