Permalink
Browse files

[GH #856] Clarify the Parrot_interp_new API for subsequent empty parents

Fixed the last blocking threads bugs, by automatically connecting subsequent new interpreters
to the very first interpreter. Revert the test changes in the previous commit.
t/src/extend_19 still fails for mysterious reasons, manually it passes, so TODO it.
  • Loading branch information...
1 parent e9dea3c commit 24f8548cb33cb3bf91ef3f4af3ee71ccc1d6ba42 @rurban rurban committed Nov 18, 2012
Showing with 14 additions and 10 deletions.
  1. +12 −2 src/interp/api.c
  2. +1 −1 t/src/embed.t
  3. +1 −7 t/src/extend.t
View
14 src/interp/api.c
@@ -87,6 +87,9 @@ Returns a new Parrot interpreter.
The first created interpreter (C<parent> is C<NULL>) is the last one
to get destroyed.
+Note that subsequently created interpreters with C<parent> C<NULL>
+will use the first interpreter as parent.
+
=cut
*/
@@ -191,9 +194,16 @@ Parrot_interp_allocate_interpreter(ARGIN_NULLOK(Interp *parent), INTVAL flags)
if (parent)
interp->parent_interpreter = parent;
else {
- interp->parent_interpreter = NULL;
- if (!emergency_interp)
+ if (!emergency_interp) {
emergency_interp = interp;
+ }
+#ifdef PARROT_HAS_THREADS
+ else {
+ interp->parent_interpreter = emergency_interp;
+ }
+#else
+ interp->parent_interpreter = NULL;
+#endif
PMCNULL = NULL;
}
View
2 t/src/embed.t
@@ -132,7 +132,7 @@ int main(int argc, const char **argv)
if (!interp1)
fail("Cannot create 1st parrot interpreter");
- interp2 = Parrot_interp_new(interp1); /* threads need subsequent interp connected */
+ interp2 = Parrot_interp_new(NULL);
if (!interp2)
fail("Cannot create 2nd parrot interpreter");
View
8 t/src/extend.t
@@ -740,11 +740,7 @@ CODE
Result is 300.
OUTPUT
-SKIP: {
- skip "threads need parent for multiple parallel interp [GH #856]", 1
- if $PConfig{HAS_THREADS};
-
- c_output_is( <<'CODE', <<'OUTPUT', 'multiple Parrot_interp_new/Parrot_x_exit cycles' );
+c_output_is( <<'CODE', <<'OUTPUT', 'multiple Parrot_interp_new/Parrot_x_exit cycles', todo => "GH #856 may fail on darwin threaded" );
#include <stdio.h>
#include "parrot/parrot.h"
@@ -798,8 +794,6 @@ Starting interp 2
Destroying interp 2
OUTPUT
-}
-
# Local Variables:
# mode: cperl
# cperl-indent-level: 4

0 comments on commit 24f8548

Please sign in to comment.