… | |
… | |
1074 | { |
1074 | { |
1075 | ANPENDING *p = pendings [pri] + --pendingcnt [pri]; |
1075 | ANPENDING *p = pendings [pri] + --pendingcnt [pri]; |
1076 | |
1076 | |
1077 | if (expect_true (p->w)) |
1077 | if (expect_true (p->w)) |
1078 | { |
1078 | { |
|
|
1079 | assert (("non-pending watcher on pending list", p->w->pending)); |
|
|
1080 | |
1079 | p->w->pending = 0; |
1081 | p->w->pending = 0; |
1080 | EV_CB_INVOKE (p->w, p->events); |
1082 | EV_CB_INVOKE (p->w, p->events); |
1081 | } |
1083 | } |
1082 | } |
1084 | } |
1083 | } |
1085 | } |
… | |
… | |
1189 | { |
1191 | { |
1190 | if (time_update_monotonic (EV_A)) |
1192 | if (time_update_monotonic (EV_A)) |
1191 | { |
1193 | { |
1192 | ev_tstamp odiff = rtmn_diff; |
1194 | ev_tstamp odiff = rtmn_diff; |
1193 | |
1195 | |
1194 | for (i = 4; --i; ) /* loop a few times, before making important decisions */ |
1196 | /* loop a few times, before making important decisions. |
|
|
1197 | * on the choice of "4": one iteration isn't enough, |
|
|
1198 | * in case we get preempted during the calls to |
|
|
1199 | * ev_time and get_clock. a second call is almost guarenteed |
|
|
1200 | * to succeed in that case, though. and looping a few more times |
|
|
1201 | * doesn't hurt either as we only do this on time-jumps or |
|
|
1202 | * in the unlikely event of getting preempted here. |
|
|
1203 | */ |
|
|
1204 | for (i = 4; --i; ) |
1195 | { |
1205 | { |
1196 | rtmn_diff = ev_rt_now - mn_now; |
1206 | rtmn_diff = ev_rt_now - mn_now; |
1197 | |
1207 | |
1198 | if (fabs (odiff - rtmn_diff) < MIN_TIMEJUMP) |
1208 | if (fabs (odiff - rtmn_diff) < MIN_TIMEJUMP) |
1199 | return; /* all is well */ |
1209 | return; /* all is well */ |
… | |
… | |
1551 | { |
1561 | { |
1552 | ev_clear_pending (EV_A_ (W)w); |
1562 | ev_clear_pending (EV_A_ (W)w); |
1553 | if (expect_false (!ev_is_active (w))) |
1563 | if (expect_false (!ev_is_active (w))) |
1554 | return; |
1564 | return; |
1555 | |
1565 | |
|
|
1566 | { |
|
|
1567 | int active = ((W)w)->active; |
1556 | idles [((W)w)->active - 1] = idles [--idlecnt]; |
1568 | idles [active - 1] = idles [--idlecnt]; |
|
|
1569 | ((W)idles [active - 1])->active = active; |
|
|
1570 | } |
|
|
1571 | |
1557 | ev_stop (EV_A_ (W)w); |
1572 | ev_stop (EV_A_ (W)w); |
1558 | } |
1573 | } |
1559 | |
1574 | |
1560 | void |
1575 | void |
1561 | ev_prepare_start (EV_P_ ev_prepare *w) |
1576 | ev_prepare_start (EV_P_ ev_prepare *w) |
… | |
… | |
1573 | { |
1588 | { |
1574 | ev_clear_pending (EV_A_ (W)w); |
1589 | ev_clear_pending (EV_A_ (W)w); |
1575 | if (expect_false (!ev_is_active (w))) |
1590 | if (expect_false (!ev_is_active (w))) |
1576 | return; |
1591 | return; |
1577 | |
1592 | |
|
|
1593 | { |
|
|
1594 | int active = ((W)w)->active; |
1578 | prepares [((W)w)->active - 1] = prepares [--preparecnt]; |
1595 | prepares [active - 1] = prepares [--preparecnt]; |
|
|
1596 | ((W)prepares [active - 1])->active = active; |
|
|
1597 | } |
|
|
1598 | |
1579 | ev_stop (EV_A_ (W)w); |
1599 | ev_stop (EV_A_ (W)w); |
1580 | } |
1600 | } |
1581 | |
1601 | |
1582 | void |
1602 | void |
1583 | ev_check_start (EV_P_ ev_check *w) |
1603 | ev_check_start (EV_P_ ev_check *w) |
… | |
… | |
1595 | { |
1615 | { |
1596 | ev_clear_pending (EV_A_ (W)w); |
1616 | ev_clear_pending (EV_A_ (W)w); |
1597 | if (expect_false (!ev_is_active (w))) |
1617 | if (expect_false (!ev_is_active (w))) |
1598 | return; |
1618 | return; |
1599 | |
1619 | |
|
|
1620 | { |
|
|
1621 | int active = ((W)w)->active; |
1600 | checks [((W)w)->active - 1] = checks [--checkcnt]; |
1622 | checks [active - 1] = checks [--checkcnt]; |
|
|
1623 | ((W)checks [active - 1])->active = active; |
|
|
1624 | } |
|
|
1625 | |
1601 | ev_stop (EV_A_ (W)w); |
1626 | ev_stop (EV_A_ (W)w); |
1602 | } |
1627 | } |
1603 | |
1628 | |
1604 | #ifndef SA_RESTART |
1629 | #ifndef SA_RESTART |
1605 | # define SA_RESTART 0 |
1630 | # define SA_RESTART 0 |