ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/State.xs
(Generate patch)

Comparing Coro/Coro/State.xs (file contents):
Revision 1.120 by root, Sat Dec 2 18:01:30 2006 UTC vs.
Revision 1.126 by root, Tue Dec 12 04:19:56 2006 UTC

38# ifndef IS_PADCONST 38# ifndef IS_PADCONST
39# define IS_PADCONST(v) 0 39# define IS_PADCONST(v) 0
40# endif 40# endif
41#endif 41#endif
42 42
43/* 5.8.7 */
44#ifndef SvRV_set
45# define SvRV_set(s,v) SvRV(s) = (v)
46#endif
47
43#include <stdio.h> 48#include <stdio.h>
44#include <errno.h> 49#include <errno.h>
50#include <assert.h>
45 51
46#if !__i386 && !__x86_64 && !__powerpc && !__m68k && !__alpha && !__mips && !__sparc64 52#if !__i386 && !__x86_64 && !__powerpc && !__m68k && !__alpha && !__mips && !__sparc64
47# undef STACKGUARD 53# undef STACKGUARD
48#endif 54#endif
49 55
90 96
91#define NOINLINE attribute ((noinline)) 97#define NOINLINE attribute ((noinline))
92 98
93#include "CoroAPI.h" 99#include "CoroAPI.h"
94 100
95#define TRANSFER_SET_STACKLEVEL 0x8bfbfbfb /* magic cookie */
96
97#ifdef USE_ITHREADS 101#ifdef USE_ITHREADS
98static perl_mutex coro_mutex; 102static perl_mutex coro_mutex;
99# define LOCK do { MUTEX_LOCK (&coro_mutex); } while (0) 103# define LOCK do { MUTEX_LOCK (&coro_mutex); } while (0)
100# define UNLOCK do { MUTEX_UNLOCK (&coro_mutex); } while (0) 104# define UNLOCK do { MUTEX_UNLOCK (&coro_mutex); } while (0)
101#else 105#else
151 coro_cctx *cctx; 155 coro_cctx *cctx;
152 156
153 /* data associated with this coroutine (initial args) */ 157 /* data associated with this coroutine (initial args) */
154 AV *args; 158 AV *args;
155 int refcnt; 159 int refcnt;
156 int flags; 160 int save; /* CORO_SAVE flags */
161 int flags; /* CF_ flags */
157 162
158 /* optionally saved, might be zero */ 163 /* optionally saved, might be zero */
159 AV *defav; 164 AV *defav; /* @_ */
160 SV *defsv; 165 SV *defsv; /* $_ */
161 SV *errsv; 166 SV *errsv; /* $@ */
167 SV *irssv; /* $/ */
168 SV *irssv_sv; /* real $/ cache */
162 169
163#define VAR(name,type) type name; 170#define VAR(name,type) type name;
164# include "state.h" 171# include "state.h"
165#undef VAR 172#undef VAR
166 173
289} 296}
290 297
291#define SB do { 298#define SB do {
292#define SE } while (0) 299#define SE } while (0)
293 300
294#define LOAD(state) load_state ((state))
295#define SAVE(state,flags) save_state ((state),(flags))
296
297#define REPLACE_SV(sv,val) SB SvREFCNT_dec (sv); (sv) = (val); (val) = 0; SE 301#define REPLACE_SV(sv,val) SB SvREFCNT_dec (sv); (sv) = (val); (val) = 0; SE
298 302
299static void 303static void
300load_state (Coro__State c) 304load_perl (Coro__State c)
301{ 305{
302#define VAR(name,type) PL_ ## name = c->name; 306#define VAR(name,type) PL_ ## name = c->name;
303# include "state.h" 307# include "state.h"
304#undef VAR 308#undef VAR
305 309
306 if (c->defav) REPLACE_SV (GvAV (PL_defgv), c->defav); 310 if (c->defav) REPLACE_SV (GvAV (PL_defgv), c->defav);
307 if (c->defsv) REPLACE_SV (DEFSV , c->defsv); 311 if (c->defsv) REPLACE_SV (DEFSV , c->defsv);
308 if (c->errsv) REPLACE_SV (ERRSV , c->errsv); 312 if (c->errsv) REPLACE_SV (ERRSV , c->errsv);
313 if (c->irssv)
314 {
315 if (c->irssv == PL_rs || sv_eq (PL_rs, c->irssv))
316 SvREFCNT_dec (c->irssv);
317 else
318 {
319 REPLACE_SV (PL_rs, c->irssv);
320 if (!c->irssv_sv) c->irssv_sv = get_sv ("/", 0);
321 sv_setsv (c->irssv_sv, PL_rs);
322 }
323 }
309 324
310 { 325 {
311 dSP; 326 dSP;
312 CV *cv; 327 CV *cv;
313 328
322 PUTBACK; 337 PUTBACK;
323 } 338 }
324} 339}
325 340
326static void 341static void
327save_state (Coro__State c, int flags) 342save_perl (Coro__State c)
328{ 343{
329 { 344 {
330 dSP; 345 dSP;
331 I32 cxix = cxstack_ix; 346 I32 cxix = cxstack_ix;
332 PERL_CONTEXT *ccstk = cxstack; 347 PERL_CONTEXT *ccstk = cxstack;
335 /* 350 /*
336 * the worst thing you can imagine happens first - we have to save 351 * the worst thing you can imagine happens first - we have to save
337 * (and reinitialize) all cv's in the whole callchain :( 352 * (and reinitialize) all cv's in the whole callchain :(
338 */ 353 */
339 354
355 EXTEND (SP, 3 + 1);
340 PUSHs (Nullsv); 356 PUSHs (Nullsv);
341 /* this loop was inspired by pp_caller */ 357 /* this loop was inspired by pp_caller */
342 for (;;) 358 for (;;)
343 { 359 {
344 while (cxix >= 0) 360 while (cxix >= 0)
350 CV *cv = cx->blk_sub.cv; 366 CV *cv = cx->blk_sub.cv;
351 367
352 if (CvDEPTH (cv)) 368 if (CvDEPTH (cv))
353 { 369 {
354 EXTEND (SP, 3); 370 EXTEND (SP, 3);
355
356 PUSHs ((SV *)CvPADLIST (cv)); 371 PUSHs ((SV *)CvPADLIST (cv));
357 PUSHs (INT2PTR (SV *, CvDEPTH (cv))); 372 PUSHs (INT2PTR (SV *, CvDEPTH (cv)));
358 PUSHs ((SV *)cv); 373 PUSHs ((SV *)cv);
359 374
360 CvDEPTH (cv) = 0; 375 CvDEPTH (cv) = 0;
361 get_padlist (cv); 376 get_padlist (cv);
362 } 377 }
363 } 378 }
364#ifdef CXt_FORMAT
365 else if (CxTYPE (cx) == CXt_FORMAT)
366 {
367 /* I never used formats, so how should I know how these are implemented? */
368 /* my bold guess is as a simple, plain sub... */
369 croak ("CXt_FORMAT not yet handled. Don't switch coroutines from within formats");
370 }
371#endif
372 } 379 }
373 380
374 if (top_si->si_type == PERLSI_MAIN) 381 if (top_si->si_type == PERLSI_MAIN)
375 break; 382 break;
376 383
380 } 387 }
381 388
382 PUTBACK; 389 PUTBACK;
383 } 390 }
384 391
385 c->defav = flags & TRANSFER_SAVE_DEFAV ? (AV *)SvREFCNT_inc (GvAV (PL_defgv)) : 0; 392 c->defav = c->save & CORO_SAVE_DEFAV ? (AV *)SvREFCNT_inc (GvAV (PL_defgv)) : 0;
386 c->defsv = flags & TRANSFER_SAVE_DEFSV ? SvREFCNT_inc (DEFSV) : 0; 393 c->defsv = c->save & CORO_SAVE_DEFSV ? SvREFCNT_inc (DEFSV) : 0;
387 c->errsv = flags & TRANSFER_SAVE_ERRSV ? SvREFCNT_inc (ERRSV) : 0; 394 c->errsv = c->save & CORO_SAVE_ERRSV ? SvREFCNT_inc (ERRSV) : 0;
395 c->irssv = c->save & CORO_SAVE_IRSSV ? SvREFCNT_inc (PL_rs) : 0;
388 396
389#define VAR(name,type)c->name = PL_ ## name; 397#define VAR(name,type)c->name = PL_ ## name;
390# include "state.h" 398# include "state.h"
391#undef VAR 399#undef VAR
392} 400}
395 * allocate various perl stacks. This is an exact copy 403 * allocate various perl stacks. This is an exact copy
396 * of perl.c:init_stacks, except that it uses less memory 404 * of perl.c:init_stacks, except that it uses less memory
397 * on the (sometimes correct) assumption that coroutines do 405 * on the (sometimes correct) assumption that coroutines do
398 * not usually need a lot of stackspace. 406 * not usually need a lot of stackspace.
399 */ 407 */
408#if USE_PERL_INIT_STACKS
409# define coro_init_stacks init_stacks
410#else
411
400static void 412static void
401coro_init_stacks () 413coro_init_stacks ()
402{ 414{
403 PL_curstackinfo = new_stackinfo(128, 1024/sizeof(PERL_CONTEXT)); 415 PL_curstackinfo = new_stackinfo(128, 1024/sizeof(PERL_CONTEXT));
404 PL_curstackinfo->si_type = PERLSI_MAIN; 416 PL_curstackinfo->si_type = PERLSI_MAIN;
443static void 455static void
444coro_destroy_stacks () 456coro_destroy_stacks ()
445{ 457{
446 if (!IN_DESTRUCT) 458 if (!IN_DESTRUCT)
447 { 459 {
448 /* is this ugly, I ask? */ 460 /* restore all saved variables and stuff */
449 LEAVE_SCOPE (0); 461 LEAVE_SCOPE (0);
462 assert (PL_tmps_floor == -1);
450 463
451 /* sure it is, but more important: is it correct?? :/ */ 464 /* free all temporaries */
452 FREETMPS; 465 FREETMPS;
466 assert (PL_tmps_ix == -1);
453 467
454 /*POPSTACK_TO (PL_mainstack);*//*D*//*use*/ 468 POPSTACK_TO (PL_mainstack);
455 } 469 }
456 470
457 while (PL_curstackinfo->si_next) 471 while (PL_curstackinfo->si_next)
458 PL_curstackinfo = PL_curstackinfo->si_next; 472 PL_curstackinfo = PL_curstackinfo->si_next;
459 473
460 while (PL_curstackinfo) 474 while (PL_curstackinfo)
461 { 475 {
462 PERL_SI *p = PL_curstackinfo->si_prev; 476 PERL_SI *p = PL_curstackinfo->si_prev;
463 477
464 { /*D*//*remove*/
465 dSP;
466 SWITCHSTACK (PL_curstack, PL_curstackinfo->si_stack);
467 PUTBACK; /* possibly superfluous */
468 }
469
470 if (!IN_DESTRUCT) 478 if (!IN_DESTRUCT)
471 {
472 dounwind (-1);/*D*//*remove*/
473 SvREFCNT_dec (PL_curstackinfo->si_stack); 479 SvREFCNT_dec (PL_curstackinfo->si_stack);
474 }
475 480
476 Safefree (PL_curstackinfo->si_cxstack); 481 Safefree (PL_curstackinfo->si_cxstack);
477 Safefree (PL_curstackinfo); 482 Safefree (PL_curstackinfo);
478 PL_curstackinfo = p; 483 PL_curstackinfo = p;
479 } 484 }
484 Safefree (PL_savestack); 489 Safefree (PL_savestack);
485#if !PERL_VERSION_ATLEAST (5,9,0) 490#if !PERL_VERSION_ATLEAST (5,9,0)
486 Safefree (PL_retstack); 491 Safefree (PL_retstack);
487#endif 492#endif
488} 493}
494#endif
489 495
490static void 496static void
491setup_coro (struct coro *coro) 497setup_coro (struct coro *coro)
492{ 498{
493 /* 499 /*
583{ 589{
584 coro_cctx *cctx; 590 coro_cctx *cctx;
585 591
586 ++cctx_count; 592 ++cctx_count;
587 593
588 New (0, cctx, 1, coro_cctx); 594 Newz (0, cctx, 1, coro_cctx);
589 595
590#if HAVE_MMAP 596#if HAVE_MMAP
591 597
592 cctx->ssize = ((STACKSIZE * sizeof (long) + PAGESIZE - 1) / PAGESIZE + STACKGUARD) * PAGESIZE; 598 cctx->ssize = ((STACKSIZE * sizeof (long) + PAGESIZE - 1) / PAGESIZE + STACKGUARD) * PAGESIZE;
593 /* mmap supposedly does allocate-on-write for us */ 599 /* mmap supposedly does allocate-on-write for us */
688 cctx_first = cctx; 694 cctx_first = cctx;
689} 695}
690 696
691/* never call directly, always through the coro_state_transfer global variable */ 697/* never call directly, always through the coro_state_transfer global variable */
692static void NOINLINE 698static void NOINLINE
693transfer (struct coro *prev, struct coro *next, int flags) 699transfer (struct coro *prev, struct coro *next)
694{ 700{
695 dSTACKLEVEL; 701 dSTACKLEVEL;
696 702
697 /* sometimes transfer is only called to set idle_sp */ 703 /* sometimes transfer is only called to set idle_sp */
698 if (flags == TRANSFER_SET_STACKLEVEL) 704 if (!next)
705 {
699 ((coro_cctx *)prev)->idle_sp = STACKLEVEL; 706 ((coro_cctx *)prev)->idle_sp = STACKLEVEL;
707 assert (((coro_cctx *)prev)->top_env = PL_top_env); /* just for the side effetc when assert is enabled */
708 }
700 else if (prev != next) 709 else if (prev != next)
701 { 710 {
702 coro_cctx *prev__cctx; 711 coro_cctx *prev__cctx;
703 712
704 if (prev->flags & CF_NEW) 713 if (prev->flags & CF_NEW)
725 if (next->flags & CF_NEW) 734 if (next->flags & CF_NEW)
726 { 735 {
727 /* need to start coroutine */ 736 /* need to start coroutine */
728 next->flags &= ~CF_NEW; 737 next->flags &= ~CF_NEW;
729 /* first get rid of the old state */ 738 /* first get rid of the old state */
730 SAVE (prev, -1); 739 save_perl (prev);
731 /* setup coroutine call */ 740 /* setup coroutine call */
732 setup_coro (next); 741 setup_coro (next);
733 /* need a new stack */ 742 /* need a new stack */
734 assert (!next->stack); 743 assert (!next->cctx);
735 } 744 }
736 else 745 else
737 { 746 {
738 /* coroutine already started */ 747 /* coroutine already started */
739 SAVE (prev, flags); 748 save_perl (prev);
740 LOAD (next); 749 load_perl (next);
741 } 750 }
742 751
743 prev__cctx = prev->cctx; 752 prev__cctx = prev->cctx;
744 753
745 /* possibly "free" the cctx */ 754 /* possibly "free" the cctx */
775} 784}
776 785
777struct transfer_args 786struct transfer_args
778{ 787{
779 struct coro *prev, *next; 788 struct coro *prev, *next;
780 int flags;
781}; 789};
782 790
783#define TRANSFER(ta) transfer ((ta).prev, (ta).next, (ta).flags) 791#define TRANSFER(ta) transfer ((ta).prev, (ta).next)
784 792
785static void 793static void
786coro_state_destroy (struct coro *coro) 794coro_state_destroy (struct coro *coro)
787{ 795{
788 if (coro->refcnt--) 796 if (coro->refcnt--)
789 return; 797 return;
790 798
791 if (coro->mainstack && coro->mainstack != main_mainstack) 799 if (coro->mainstack && coro->mainstack != main_mainstack)
792 { 800 {
793 struct coro temp; 801 struct coro temp;
802 Zero (&temp, 1, struct coro);
803 temp.save = CORO_SAVE_ALL;
794 804
795 if (coro->flags & CF_RUNNING) 805 if (coro->flags & CF_RUNNING)
796 croak ("FATAL: tried to destroy currently running coroutine"); 806 croak ("FATAL: tried to destroy currently running coroutine");
797 807
798 SAVE ((&temp), TRANSFER_SAVE_ALL); 808 save_perl (&temp);
799 LOAD (coro); 809 load_perl (coro);
800 810
801 coro_destroy_stacks (); 811 coro_destroy_stacks ();
802 812
803 LOAD ((&temp)); /* this will get rid of defsv etc.. */ 813 load_perl (&temp); /* this will get rid of defsv etc.. */
804 814
805 coro->mainstack = 0; 815 coro->mainstack = 0;
806 } 816 }
807 817
808 cctx_destroy (coro->cctx); 818 cctx_destroy (coro->cctx);
863 assert (mg->mg_type == PERL_MAGIC_ext); 873 assert (mg->mg_type == PERL_MAGIC_ext);
864 return (struct coro *)mg->mg_ptr; 874 return (struct coro *)mg->mg_ptr;
865} 875}
866 876
867static void 877static void
868prepare_transfer (struct transfer_args *ta, SV *prev, SV *next, int flags) 878prepare_transfer (struct transfer_args *ta, SV *prev_sv, SV *next_sv)
869{ 879{
870 ta->prev = SvSTATE (prev); 880 ta->prev = SvSTATE (prev_sv);
871 ta->next = SvSTATE (next); 881 ta->next = SvSTATE (next_sv);
872 ta->flags = flags;
873} 882}
874 883
875static void 884static void
876api_transfer (SV *prev, SV *next, int flags) 885api_transfer (SV *prev_sv, SV *next_sv)
877{ 886{
878 struct transfer_args ta; 887 struct transfer_args ta;
879 888
880 prepare_transfer (&ta, prev, next, flags); 889 prepare_transfer (&ta, prev_sv, next_sv);
881 TRANSFER (ta); 890 TRANSFER (ta);
891}
892
893static int
894api_save (SV *coro_sv, int new_save)
895{
896 struct coro *coro = SvSTATE (coro_sv);
897 int old_save = coro->save;
898
899 if (new_save >= 0)
900 coro->save = new_save;
901
902 return old_save;
882} 903}
883 904
884/** Coro ********************************************************************/ 905/** Coro ********************************************************************/
885 906
886#define PRIO_MAX 3 907#define PRIO_MAX 3
995 assert (!SvROK(prev));//D 1016 assert (!SvROK(prev));//D
996 assert (!SvROK(next));//D 1017 assert (!SvROK(next));//D
997 1018
998 ta->prev = SvSTATE (prev); 1019 ta->prev = SvSTATE (prev);
999 ta->next = SvSTATE (next); 1020 ta->next = SvSTATE (next);
1000 ta->flags = TRANSFER_SAVE_ALL;
1001 1021
1002 assert (ta->flags & CF_READY); 1022 assert (ta->next->flags & CF_READY);
1003 ta->next->flags &= ~CF_READY; 1023 ta->next->flags &= ~CF_READY;
1004} 1024}
1005 1025
1006static void 1026static void
1007prepare_cede (struct transfer_args *ta) 1027prepare_cede (struct transfer_args *ta)
1040#endif 1060#endif
1041 BOOT_PAGESIZE; 1061 BOOT_PAGESIZE;
1042 1062
1043 coro_state_stash = gv_stashpv ("Coro::State", TRUE); 1063 coro_state_stash = gv_stashpv ("Coro::State", TRUE);
1044 1064
1045 newCONSTSUB (coro_state_stash, "SAVE_DEFAV", newSViv (TRANSFER_SAVE_DEFAV)); 1065 newCONSTSUB (coro_state_stash, "SAVE_DEFAV", newSViv (CORO_SAVE_DEFAV));
1046 newCONSTSUB (coro_state_stash, "SAVE_DEFSV", newSViv (TRANSFER_SAVE_DEFSV)); 1066 newCONSTSUB (coro_state_stash, "SAVE_DEFSV", newSViv (CORO_SAVE_DEFSV));
1047 newCONSTSUB (coro_state_stash, "SAVE_ERRSV", newSViv (TRANSFER_SAVE_ERRSV)); 1067 newCONSTSUB (coro_state_stash, "SAVE_ERRSV", newSViv (CORO_SAVE_ERRSV));
1068 newCONSTSUB (coro_state_stash, "SAVE_IRSSV", newSViv (CORO_SAVE_IRSSV));
1069 newCONSTSUB (coro_state_stash, "SAVE_ALL", newSViv (CORO_SAVE_ALL));
1048 1070
1049 main_mainstack = PL_mainstack; 1071 main_mainstack = PL_mainstack;
1050 1072
1051 coroapi.ver = CORO_API_VERSION; 1073 coroapi.ver = CORO_API_VERSION;
1052 coroapi.transfer = api_transfer; 1074 coroapi.transfer = api_transfer;
1062 HV *hv; 1084 HV *hv;
1063 int i; 1085 int i;
1064 1086
1065 Newz (0, coro, 1, struct coro); 1087 Newz (0, coro, 1, struct coro);
1066 coro->args = newAV (); 1088 coro->args = newAV ();
1089 coro->save = CORO_SAVE_ALL;
1067 coro->flags = CF_NEW; 1090 coro->flags = CF_NEW;
1068 1091
1069 hv = newHV (); 1092 hv = newHV ();
1070 sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, &coro_state_vtbl, (char *)coro, 0)->mg_flags |= MGf_DUP; 1093 sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, &coro_state_vtbl, (char *)coro, 0)->mg_flags |= MGf_DUP;
1071 RETVAL = sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); 1094 RETVAL = sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1));
1072 1095
1073 for (i = 1; i < items; i++) 1096 for (i = 1; i < items; i++)
1074 av_push (coro->args, newSVsv (ST (i))); 1097 av_push (coro->args, newSVsv (ST (i)));
1075} 1098}
1076 OUTPUT: 1099 OUTPUT:
1100 RETVAL
1101
1102int
1103save (SV *coro, int new_save = -1)
1104 CODE:
1105 RETVAL = api_save (coro, new_save);
1106 OUTPUT:
1077 RETVAL 1107 RETVAL
1078 1108
1079void 1109void
1080_set_stacklevel (...) 1110_set_stacklevel (...)
1081 ALIAS: 1111 ALIAS:
1089 switch (ix) 1119 switch (ix)
1090 { 1120 {
1091 case 0: 1121 case 0:
1092 ta.prev = (struct coro *)INT2PTR (coro_cctx *, SvIV (ST (0))); 1122 ta.prev = (struct coro *)INT2PTR (coro_cctx *, SvIV (ST (0)));
1093 ta.next = 0; 1123 ta.next = 0;
1094 ta.flags = TRANSFER_SET_STACKLEVEL;
1095 break; 1124 break;
1096 1125
1097 case 1: 1126 case 1:
1098 if (items != 3) 1127 if (items != 2)
1099 croak ("Coro::State::transfer (prev,next,flags) expects three arguments, not %d", items); 1128 croak ("Coro::State::transfer (prev,next) expects two arguments, not %d", items);
1100 1129
1101 prepare_transfer (&ta, ST (0), ST (1), SvIV (ST (2))); 1130 prepare_transfer (&ta, ST (0), ST (1));
1102 break; 1131 break;
1103 1132
1104 case 2: 1133 case 2:
1105 prepare_schedule (&ta); 1134 prepare_schedule (&ta);
1106 break; 1135 break;
1169 1198
1170 { 1199 {
1171 SV *sv = perl_get_sv("Coro::API", 1); 1200 SV *sv = perl_get_sv("Coro::API", 1);
1172 1201
1173 coroapi.schedule = api_schedule; 1202 coroapi.schedule = api_schedule;
1203 coroapi.save = api_save;
1174 coroapi.cede = api_cede; 1204 coroapi.cede = api_cede;
1175 coroapi.ready = api_ready; 1205 coroapi.ready = api_ready;
1176 coroapi.is_ready = api_is_ready; 1206 coroapi.is_ready = api_is_ready;
1177 coroapi.nready = &coro_nready; 1207 coroapi.nready = &coro_nready;
1178 coroapi.current = coro_current; 1208 coroapi.current = coro_current;
1180 GCoroAPI = &coroapi; 1210 GCoroAPI = &coroapi;
1181 sv_setiv (sv, (IV)&coroapi); 1211 sv_setiv (sv, (IV)&coroapi);
1182 SvREADONLY_on (sv); 1212 SvREADONLY_on (sv);
1183 } 1213 }
1184} 1214}
1215
1216void
1217_set_current (SV *current)
1218 PROTOTYPE: $
1219 CODE:
1220 SvREFCNT_dec (SvRV (coro_current));
1221 SvRV_set (coro_current, SvREFCNT_inc (SvRV (current)));
1185 1222
1186int 1223int
1187prio (Coro::State coro, int newprio = 0) 1224prio (Coro::State coro, int newprio = 0)
1188 ALIAS: 1225 ALIAS:
1189 nice = 1 1226 nice = 1
1225 CODE: 1262 CODE:
1226 RETVAL = coro_nready; 1263 RETVAL = coro_nready;
1227 OUTPUT: 1264 OUTPUT:
1228 RETVAL 1265 RETVAL
1229 1266
1230void
1231_set_current (SV *current)
1232 PROTOTYPE: $
1233 CODE:
1234 SvREFCNT_dec (SvRV (coro_current));
1235 SvRV_set (coro_current, SvREFCNT_inc (SvRV (current)));
1236
1237MODULE = Coro::State PACKAGE = Coro::AIO 1267MODULE = Coro::State PACKAGE = Coro::AIO
1238 1268
1239SV * 1269SV *
1240_get_state () 1270_get_state ()
1241 CODE: 1271 CODE:
1242{ 1272{
1273 struct io_state *data;
1274
1243 RETVAL = newSV (sizeof (struct io_state)); 1275 RETVAL = newSV (sizeof (struct io_state));
1244 struct io_state *data = (struct io_state *)SvPVX (RETVAL); 1276 data = (struct io_state *)SvPVX (RETVAL);
1245 SvCUR_set (RETVAL, sizeof (struct io_state)); 1277 SvCUR_set (RETVAL, sizeof (struct io_state));
1246 SvPOK_only (RETVAL); 1278 SvPOK_only (RETVAL);
1247 1279
1248 data->errorno = errno; 1280 data->errorno = errno;
1249 data->laststype = PL_laststype; 1281 data->laststype = PL_laststype;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines