threads 1.64 (repost)
[p5sagit/p5-mst-13.2.git] / ext / threads / threads.xs
index eb96414..e1414de 100755 (executable)
@@ -637,7 +637,7 @@ S_ithread_create(
      * 1 ref to be the responsibility of join/detach, so we don't get
      *      freed until join/detach, even if no thread objects remain.
      *      This allows the following to work:
-     *          { threads->new(sub{...}); } threads->object(1)->join;
+     *          { threads->create(sub{...}); } threads->object(1)->join;
      */
     thread->count = 3;
 
@@ -688,10 +688,8 @@ S_ithread_create(
             thread->init_function = newSV(0);
             sv_copypv(thread->init_function, init_function);
         } else {
-            thread->init_function = sv_dup(init_function, &clone_param);
-            if (SvREFCNT(thread->init_function) == 0) {
-                SvREFCNT_inc_void(thread->init_function);
-            }
+            thread->init_function =
+               SvREFCNT_inc(sv_dup(init_function, &clone_param));
         }
 
         thread->params = sv_dup(params, &clone_param);
@@ -848,7 +846,7 @@ ithread_create(...)
     CODE:
         if ((items >= 2) && SvROK(ST(1)) && SvTYPE(SvRV(ST(1)))==SVt_PVHV) {
             if (--items < 2) {
-                Perl_croak(aTHX_ "Usage: threads->create(\\%specs, function, ...)");
+                Perl_croak(aTHX_ "Usage: threads->create(\\%%specs, function, ...)");
             }
             specs = (HV*)SvRV(ST(1));
             idx = 1;
@@ -896,6 +894,8 @@ ithread_create(...)
                 switch (*str) {
                     case 'a':
                     case 'A':
+                    case 'l':
+                    case 'L':
                         context = G_ARRAY;
                         break;
                     case 's':
@@ -913,6 +913,10 @@ ithread_create(...)
                 if (SvTRUE(*hv_fetch(specs, "array", 5, 0))) {
                     context = G_ARRAY;
                 }
+            } else if (hv_exists(specs, "list", 4)) {
+                if (SvTRUE(*hv_fetch(specs, "list", 4, 0))) {
+                    context = G_ARRAY;
+                }
             } else if (hv_exists(specs, "scalar", 6)) {
                 if (SvTRUE(*hv_fetch(specs, "scalar", 6, 0))) {
                     context = G_SCALAR;
@@ -1067,9 +1071,7 @@ ithread_join(...)
         AV *params = NULL;
         int len;
         int ii;
-#ifdef WIN32
-        DWORD waitcode;
-#else
+#ifndef WIN32
         int rc_join;
         void *retval;
 #endif