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.441 by root, Tue Mar 4 05:07:44 2014 UTC vs.
Revision 1.447 by root, Tue Oct 14 21:53:32 2014 UTC

1138 1138
1139 GvSV (PL_defgv) = newSV (0); 1139 GvSV (PL_defgv) = newSV (0);
1140 GvAV (PL_defgv) = coro->args; coro->args = 0; 1140 GvAV (PL_defgv) = coro->args; coro->args = 0;
1141 GvSV (PL_errgv) = newSV (0); 1141 GvSV (PL_errgv) = newSV (0);
1142 GvSV (irsgv) = newSVpvn ("\n", 1); sv_magic (GvSV (irsgv), (SV *)irsgv, PERL_MAGIC_sv, "/", 0); 1142 GvSV (irsgv) = newSVpvn ("\n", 1); sv_magic (GvSV (irsgv), (SV *)irsgv, PERL_MAGIC_sv, "/", 0);
1143 GvHV (PL_hintgv) = 0; 1143 GvHV (PL_hintgv) = newHV ();
1144#if PERL_VERSION_ATLEAST (5,10,0)
1145 hv_magic (GvHV (PL_hintgv), 0, PERL_MAGIC_hints);
1146#endif
1144 PL_rs = newSVsv (GvSV (irsgv)); 1147 PL_rs = newSVsv (GvSV (irsgv));
1145 PL_defoutgv = (GV *)SvREFCNT_inc_NN (stdoutgv); 1148 PL_defoutgv = (GV *)SvREFCNT_inc_NN (stdoutgv);
1146 1149
1147 { 1150 {
1148 dSP; 1151 dSP;
1927 1930
1928 ENTER; 1931 ENTER;
1929 SAVETMPS; 1932 SAVETMPS;
1930 1933
1931 PUSHMARK (SP); 1934 PUSHMARK (SP);
1932 XPUSHs (sv_2mortal (newSVpv ("FATAL: $Coro::IDLE blocked itself - did you try to block inside an event loop callback? Caught", 0))); 1935 XPUSHs (sv_2mortal (newSVpv ("FATAL: $Coro::idle blocked itself - did you try to block inside an event loop callback? Caught", 0)));
1933 PUTBACK; 1936 PUTBACK;
1934 call_pv ("Carp::confess", G_VOID | G_DISCARD); 1937 call_pv ("Carp::confess", G_VOID | G_DISCARD);
1935 1938
1936 FREETMPS; 1939 FREETMPS;
1937 LEAVE; 1940 LEAVE;
2248 slf_init_terminate_cancel_common (aTHX_ frame, coro_hv); 2251 slf_init_terminate_cancel_common (aTHX_ frame, coro_hv);
2249 } 2252 }
2250 else 2253 else
2251 { 2254 {
2252 struct coro *self = SvSTATE_current; 2255 struct coro *self = SvSTATE_current;
2256
2257 if (!self)
2258 croak ("Coro::cancel called outside of thread content,");
2253 2259
2254 /* otherwise we cancel directly, purely for speed reasons 2260 /* otherwise we cancel directly, purely for speed reasons
2255 * unfortunately, this requires some magic trickery, as 2261 * unfortunately, this requires some magic trickery, as
2256 * somebody else could cancel us, so we have to fight the cancellation. 2262 * somebody else could cancel us, so we have to fight the cancellation.
2257 * this is ugly, and hopefully fully worth the extra speed. 2263 * this is ugly, and hopefully fully worth the extra speed.
2608 * Since by definition the SLF call will not finish when we destroy 2614 * Since by definition the SLF call will not finish when we destroy
2609 * the coro, we will have to force-finish it here, otherwise 2615 * the coro, we will have to force-finish it here, otherwise
2610 * cleanup functions cannot call SLF functions. 2616 * cleanup functions cannot call SLF functions.
2611 */ 2617 */
2612 coro->slf_frame.prepare = 0; 2618 coro->slf_frame.prepare = 0;
2613 coro->slf_frame.destroy = 0;
2614 2619
2615 /* this callback is reserved for slf functions needing to do cleanup */ 2620 /* this callback is reserved for slf functions needing to do cleanup */
2616 if (frame.destroy && frame.prepare && !PL_dirty) 2621 if (frame.destroy && frame.prepare && !PL_dirty)
2617 frame.destroy (aTHX_ &frame); 2622 frame.destroy (aTHX_ &frame);
2618} 2623}
2962{ 2967{
2963 AV *av = (AV *)frame->data; 2968 AV *av = (AV *)frame->data;
2964 SV *count_sv = AvARRAY (av)[0]; 2969 SV *count_sv = AvARRAY (av)[0];
2965 SV *coro_hv = SvRV (coro_current); 2970 SV *coro_hv = SvRV (coro_current);
2966 2971
2972 frame->destroy = 0;
2973
2967 /* if we are about to throw, don't actually acquire the lock, just throw */ 2974 /* if we are about to throw, don't actually acquire the lock, just throw */
2968 if (CORO_THROW) 2975 if (ecb_expect_false (CORO_THROW))
2976 {
2977 /* we still might be responsible for the semaphore, so wake up others */
2978 coro_semaphore_adjust (aTHX_ av, 0);
2979
2969 return 0; 2980 return 0;
2981 }
2970 else if (SvIVX (count_sv) > 0) 2982 else if (SvIVX (count_sv) > 0)
2971 { 2983 {
2972 frame->destroy = 0;
2973
2974 if (acquire) 2984 if (acquire)
2975 SvIVX (count_sv) = SvIVX (count_sv) - 1; 2985 SvIVX (count_sv) = SvIVX (count_sv) - 1;
2976 else 2986 else
2977 coro_semaphore_adjust (aTHX_ av, 0); 2987 coro_semaphore_adjust (aTHX_ av, 0);
2978 2988
3438 3448
3439PROTOTYPES: DISABLE 3449PROTOTYPES: DISABLE
3440 3450
3441BOOT: 3451BOOT:
3442{ 3452{
3453#define VARx(name,expr,type) if (sizeof (type) < sizeof (expr)) croak ("FATAL: Coro thread context slot '" # name "' too small for this version of perl.");
3454#include "state.h"
3443#ifdef USE_ITHREADS 3455#ifdef USE_ITHREADS
3444# if CORO_PTHREAD 3456# if CORO_PTHREAD
3445 coro_thx = PERL_GET_CONTEXT; 3457 coro_thx = PERL_GET_CONTEXT;
3446# endif 3458# endif
3447#endif 3459#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines