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.57 by pcg, Thu Apr 22 04:14:49 2004 UTC vs.
Revision 1.60 by root, Mon Aug 9 02:41:27 2004 UTC

69static struct CoroAPI coroapi; 69static struct CoroAPI coroapi;
70static AV *main_mainstack; /* used to differentiate between $main and others */ 70static AV *main_mainstack; /* used to differentiate between $main and others */
71static HV *coro_state_stash; 71static HV *coro_state_stash;
72static SV *ucoro_state_sv; 72static SV *ucoro_state_sv;
73static U32 ucoro_state_hash; 73static U32 ucoro_state_hash;
74static __thread SV *coro_mortal; /* will be freed after next transfer */ 74static SV *coro_mortal; /* will be freed after next transfer */
75 75
76/* this is actually not only the c stack but also c registers etc... */ 76/* this is actually not only the c stack but also c registers etc... */
77typedef struct { 77typedef struct {
78 int refcnt; /* pointer reference counter */ 78 int refcnt; /* pointer reference counter */
79 int usecnt; /* shared by how many coroutines */ 79 int usecnt; /* shared by how many coroutines */
979 croak ("Coro::State::_newprocess expects an arrayref"); 979 croak ("Coro::State::_newprocess expects an arrayref");
980 980
981 Newz (0, coro, 1, struct coro); 981 Newz (0, coro, 1, struct coro);
982 982
983 coro->args = (AV *)SvREFCNT_inc (SvRV (args)); 983 coro->args = (AV *)SvREFCNT_inc (SvRV (args));
984 coro->mainstack = 0; /* actual work is done inside transfer */ 984 /*coro->mainstack = 0; *//*actual work is done inside transfer */
985 coro->stack = 0; 985 /*coro->stack = 0;*/
986 986
987 /* same as JMPENV_BOOTSTRAP */ 987 /* same as JMPENV_BOOTSTRAP */
988 /* we might be able to recycle start_env, but safe is safe */ 988 /* we might be able to recycle start_env, but safe is safe */
989 //Zero(&coro->start_env, 1, JMPENV); 989 /*Zero(&coro->start_env, 1, JMPENV);*/
990 coro->start_env.je_ret = -1; 990 coro->start_env.je_ret = -1;
991 coro->start_env.je_mustcatch = TRUE; 991 coro->start_env.je_mustcatch = TRUE;
992 992
993 RETVAL = coro; 993 RETVAL = coro;
994 OUTPUT: 994 OUTPUT:
1015 if (coro->mainstack && coro->mainstack != main_mainstack) 1015 if (coro->mainstack && coro->mainstack != main_mainstack)
1016 { 1016 {
1017 struct coro temp; 1017 struct coro temp;
1018 1018
1019 PUTBACK; 1019 PUTBACK;
1020 SAVE(aTHX_ (&temp), TRANSFER_SAVE_ALL); 1020 SAVE (aTHX_ (&temp), TRANSFER_SAVE_ALL);
1021 LOAD(aTHX_ coro); 1021 LOAD (aTHX_ coro);
1022 SPAGAIN; 1022 SPAGAIN;
1023 1023
1024 destroy_stacks (aTHX); 1024 destroy_stacks (aTHX);
1025 1025
1026 LOAD((&temp)); /* this will get rid of defsv etc.. */ 1026 LOAD ((&temp)); /* this will get rid of defsv etc.. */
1027 SPAGAIN; 1027 SPAGAIN;
1028 1028
1029 coro->mainstack = 0; 1029 coro->mainstack = 0;
1030 } 1030 }
1031 1031
1060 av_clear (defav); 1060 av_clear (defav);
1061 av_fill (defav, items - 1); 1061 av_fill (defav, items - 1);
1062 while (items--) 1062 while (items--)
1063 av_store (defav, items, SvREFCNT_inc (ST(items))); 1063 av_store (defav, items, SvREFCNT_inc (ST(items)));
1064 1064
1065 mg_get (returnstk); /* isn't documentation wrong for mg_get? */ 1065 SvGETMAGIC (returnstk); /* isn't documentation wrong for mg_get? */
1066 sv = av_pop ((AV *)SvRV (returnstk)); 1066 sv = av_pop ((AV *)SvRV (returnstk));
1067 prev = (struct coro *)SvIV ((SV*)SvRV (*av_fetch ((AV *)SvRV (sv), 0, 0))); 1067 prev = (struct coro *)SvIV ((SV*)SvRV (*av_fetch ((AV *)SvRV (sv), 0, 0)));
1068 next = (struct coro *)SvIV ((SV*)SvRV (*av_fetch ((AV *)SvRV (sv), 1, 0))); 1068 next = (struct coro *)SvIV ((SV*)SvRV (*av_fetch ((AV *)SvRV (sv), 1, 0)));
1069 SvREFCNT_dec (sv); 1069 SvREFCNT_dec (sv);
1070 1070
1071 transfer(aTHX_ prev, next, 0); 1071 transfer (aTHX_ prev, next, 0);
1072 1072
1073MODULE = Coro::State PACKAGE = Coro 1073MODULE = Coro::State PACKAGE = Coro
1074 1074
1075# this is slightly dirty (should expose a c-level api) 1075# this is slightly dirty (should expose a c-level api)
1076 1076

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines