[macruby-changes] [2361] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Sun Aug 23 18:32:29 PDT 2009


Revision: 2361
          http://trac.macosforge.org/projects/ruby/changeset/2361
Author:   lsansonetti at apple.com
Date:     2009-08-23 18:32:25 -0700 (Sun, 23 Aug 2009)
Log Message:
-----------
exposing an API to control the multithreaded state, that will be very useful later

Modified Paths:
--------------
    MacRuby/trunk/vm.cpp
    MacRuby/trunk/vm.h

Modified: MacRuby/trunk/vm.cpp
===================================================================
--- MacRuby/trunk/vm.cpp	2009-08-24 00:45:50 UTC (rev 2360)
+++ MacRuby/trunk/vm.cpp	2009-08-24 01:32:25 UTC (rev 2361)
@@ -508,18 +508,22 @@
 inline rb_vm_method_node_t *
 RoxorCore::method_node_get(Method m, bool create)
 {
+    rb_vm_method_node_t *n;
     std::map<Method, rb_vm_method_node_t *>::iterator iter =
 	ruby_methods.find(m);
     if (iter == ruby_methods.end()) {
 	if (create) {
-	    rb_vm_method_node_t *n =
-		(rb_vm_method_node_t *)malloc(sizeof(rb_vm_method_node_t));
+	    n = (rb_vm_method_node_t *)malloc(sizeof(rb_vm_method_node_t));
 	    ruby_methods[m] = n;
-	    return n;
 	}
-	return NULL;
+	else {
+	    n = NULL;
+	}
     }
-    return iter->second;
+    else {
+	n = iter->second;
+    }
+    return n;
 }
 
 extern "C"
@@ -4827,7 +4831,21 @@
     return (void *)new RoxorVM(*GET_VM());
 }
 
+extern "C"
+bool
+rb_vm_is_multithreaded(void)
+{
+    return GET_CORE()->get_multithreaded();
+}
+
+extern "C"
 void
+rb_vm_set_multithreaded(bool flag)
+{
+    GET_CORE()->set_multithreaded(flag);
+}
+
+void
 RoxorCore::register_thread(VALUE thread)
 {
     lock();

Modified: MacRuby/trunk/vm.h
===================================================================
--- MacRuby/trunk/vm.h	2009-08-24 00:45:50 UTC (rev 2360)
+++ MacRuby/trunk/vm.h	2009-08-24 01:32:25 UTC (rev 2361)
@@ -373,6 +373,9 @@
 bool rb_vm_abort_on_exception(void);
 void rb_vm_set_abort_on_exception(bool flag);
 
+bool rb_vm_is_multithreaded(void);
+void rb_vm_set_multithreaded(bool flag);
+
 static inline VALUE
 rb_robject_allocate_instance(VALUE klass)
 {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090823/13b97c17/attachment.html>


More information about the macruby-changes mailing list