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.234 by root, Fri May 9 22:29:05 2008 UTC vs.
Revision 1.237 by root, Fri May 23 00:27:06 2008 UTC

1383static int 1383static int
1384api_ready (SV *coro_sv) 1384api_ready (SV *coro_sv)
1385{ 1385{
1386 dTHX; 1386 dTHX;
1387 struct coro *coro; 1387 struct coro *coro;
1388 SV *hook; 1388 SV *sv_hook;
1389 void (*xs_hook)(void);
1389 1390
1390 if (SvROK (coro_sv)) 1391 if (SvROK (coro_sv))
1391 coro_sv = SvRV (coro_sv); 1392 coro_sv = SvRV (coro_sv);
1392 1393
1393 coro = SvSTATE (coro_sv); 1394 coro = SvSTATE (coro_sv);
1397 1398
1398 coro->flags |= CF_READY; 1399 coro->flags |= CF_READY;
1399 1400
1400 LOCK; 1401 LOCK;
1401 1402
1402 hook = coro_nready ? 0 : coro_readyhook; 1403 sv_hook = coro_nready ? 0 : coro_readyhook;
1404 xs_hook = coro_nready ? 0 : coroapi.readyhook;
1403 1405
1404 coro_enq (aTHX_ SvREFCNT_inc (coro_sv)); 1406 coro_enq (aTHX_ SvREFCNT_inc (coro_sv));
1405 ++coro_nready; 1407 ++coro_nready;
1406 1408
1407 UNLOCK; 1409 UNLOCK;
1408 1410
1409 if (hook) 1411 if (sv_hook)
1410 { 1412 {
1411 dSP; 1413 dSP;
1412 1414
1413 ENTER; 1415 ENTER;
1414 SAVETMPS; 1416 SAVETMPS;
1415 1417
1416 PUSHMARK (SP); 1418 PUSHMARK (SP);
1417 PUTBACK; 1419 PUTBACK;
1418 call_sv (hook, G_DISCARD); 1420 call_sv (sv_hook, G_DISCARD);
1419 SPAGAIN; 1421 SPAGAIN;
1420 1422
1421 FREETMPS; 1423 FREETMPS;
1422 LEAVE; 1424 LEAVE;
1423 } 1425 }
1426
1427 if (xs_hook)
1428 xs_hook ();
1424 1429
1425 return 1; 1430 return 1;
1426} 1431}
1427 1432
1428static int 1433static int
1614 main_top_env = PL_top_env; 1619 main_top_env = PL_top_env;
1615 1620
1616 while (main_top_env->je_prev) 1621 while (main_top_env->je_prev)
1617 main_top_env = main_top_env->je_prev; 1622 main_top_env = main_top_env->je_prev;
1618 1623
1619 coroapi.ver = CORO_API_VERSION; 1624 coroapi.ver = CORO_API_VERSION;
1620 coroapi.rev = CORO_API_REVISION; 1625 coroapi.rev = CORO_API_REVISION;
1621 coroapi.transfer = api_transfer; 1626 coroapi.transfer = api_transfer;
1622 1627
1623 assert (("PRIO_NORMAL must be 0", !PRIO_NORMAL)); 1628 assert (("PRIO_NORMAL must be 0", !PRIO_NORMAL));
1624} 1629}
1625 1630
1626SV * 1631SV *
1901void 1906void
1902_set_readyhook (SV *hook) 1907_set_readyhook (SV *hook)
1903 PROTOTYPE: $ 1908 PROTOTYPE: $
1904 CODE: 1909 CODE:
1905 LOCK; 1910 LOCK;
1906 if (coro_readyhook)
1907 SvREFCNT_dec (coro_readyhook); 1911 SvREFCNT_dec (coro_readyhook);
1908 coro_readyhook = SvOK (hook) ? newSVsv (hook) : 0; 1912 coro_readyhook = SvOK (hook) ? newSVsv (hook) : 0;
1909 UNLOCK; 1913 UNLOCK;
1910 1914
1911int 1915int
1912prio (Coro::State coro, int newprio = 0) 1916prio (Coro::State coro, int newprio = 0)
2078 2082
2079BOOT: 2083BOOT:
2080 sv_activity = coro_get_sv (aTHX_ "Coro::AnyEvent::ACTIVITY", TRUE); 2084 sv_activity = coro_get_sv (aTHX_ "Coro::AnyEvent::ACTIVITY", TRUE);
2081 2085
2082SV * 2086SV *
2083_schedule () 2087_schedule (...)
2084 PROTOTYPE: @ 2088 PROTOTYPE: @
2085 CODE: 2089 CODE:
2086{ 2090{
2087 static int incede; 2091 static int incede;
2088 fprintf (stderr, "_schedule\n");//D
2089 2092
2090 api_cede_notself (); 2093 api_cede_notself ();
2091 2094
2092 ++incede; 2095 ++incede;
2093 while (coro_nready >= incede && api_cede ()) 2096 while (coro_nready >= incede && api_cede ())
2096 sv_setsv (sv_activity, &PL_sv_undef); 2099 sv_setsv (sv_activity, &PL_sv_undef);
2097 if (coro_nready >= incede) 2100 if (coro_nready >= incede)
2098 { 2101 {
2099 PUSHMARK (SP); 2102 PUSHMARK (SP);
2100 PUTBACK; 2103 PUTBACK;
2101 fprintf (stderr, "call act %d >= %d\n", coro_nready, incede);//D
2102 call_pv ("Coro::AnyEvent::_activity", G_DISCARD | G_EVAL); 2104 call_pv ("Coro::AnyEvent::_activity", G_DISCARD | G_EVAL);
2103 SPAGAIN; 2105 SPAGAIN;
2104 } 2106 }
2105 2107
2106 --incede; 2108 --incede;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines