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.206 by root, Tue Oct 9 15:45:26 2007 UTC vs.
Revision 1.207 by root, Tue Oct 9 22:29:27 2007 UTC

1561# function to increase chances that they all will call transfer with the same 1561# function to increase chances that they all will call transfer with the same
1562# stack offset 1562# stack offset
1563void 1563void
1564_set_stacklevel (...) 1564_set_stacklevel (...)
1565 ALIAS: 1565 ALIAS:
1566 Coro::State::transfer = 1 1566 Coro::State::transfer = 1
1567 Coro::schedule = 2 1567 Coro::schedule = 2
1568 Coro::cede = 3 1568 Coro::cede = 3
1569 Coro::cede_notself = 4 1569 Coro::cede_notself = 4
1570 Coro::Event::next = 5
1571 Coro::Event::next_cancel = 6
1570 CODE: 1572 PPCODE:
1571{ 1573{
1572 struct transfer_args ta; 1574 struct transfer_args ta;
1575 int repeat = 0;
1573 1576
1574 switch (ix) 1577 do
1575 { 1578 {
1579 switch (ix)
1580 {
1576 case 0: 1581 case 0:
1577 ta.prev = (struct coro *)INT2PTR (coro_cctx *, SvIV (ST (0))); 1582 ta.prev = (struct coro *)INT2PTR (coro_cctx *, SvIV (ST (0)));
1578 ta.next = 0; 1583 ta.next = 0;
1579 break; 1584 break;
1580 1585
1581 case 1: 1586 case 1:
1582 if (items != 2) 1587 if (items != 2)
1583 croak ("Coro::State::transfer (prev,next) expects two arguments, not %d", items); 1588 croak ("Coro::State::transfer (prev,next) expects two arguments, not %d", items);
1584 1589
1585 prepare_transfer (aTHX_ &ta, ST (0), ST (1)); 1590 prepare_transfer (aTHX_ &ta, ST (0), ST (1));
1586 break; 1591 break;
1587 1592
1588 case 2: 1593 case 2:
1589 prepare_schedule (aTHX_ &ta); 1594 prepare_schedule (aTHX_ &ta);
1590 break; 1595 break;
1591 1596
1592 case 3: 1597 case 3:
1593 prepare_cede (aTHX_ &ta); 1598 prepare_cede (aTHX_ &ta);
1594 break; 1599 break;
1595 1600
1596 case 4: 1601 case 4:
1597 if (!prepare_cede_notself (aTHX_ &ta)) 1602 if (!prepare_cede_notself (aTHX_ &ta))
1598 XSRETURN_EMPTY; 1603 XSRETURN_EMPTY;
1599 1604
1600 break; 1605 break;
1606
1607 case 5:
1608 case 6:
1609 if (items != 1)
1610 croak ("Coro::Event::next (watcher) expects one argument, not %d", items);
1611
1612 {
1613 SV *ev = coroapi.coro_event_next (ST (0), ix == 6, GIMME_V != G_VOID);
1614
1615 if (ev)
1616 {
1617 if (GIMME_V != G_VOID)
1618 {
1619 XPUSHs (ev);
1620 XSRETURN (1);
1621 }
1622 else
1623 XSRETURN_EMPTY;
1624 }
1625 }
1626
1627 prepare_schedule (aTHX_ &ta);
1628 repeat = 1;
1629 break;
1630 }
1631
1632 BARRIER;
1633 TRANSFER (ta);
1634 BARRIER;
1601 } 1635 }
1602 1636 while (repeat);
1603 BARRIER;
1604 TRANSFER (ta);
1605 1637
1606 if (expect_false (GIMME_V != G_VOID && ta.next != ta.prev)) 1638 if (expect_false (GIMME_V != G_VOID && ta.next != ta.prev))
1607 XSRETURN_YES; 1639 XSRETURN_YES;
1608} 1640}
1609 1641

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines