1 | .\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) |
1 | .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) |
2 | .\" |
2 | .\" |
3 | .\" Standard preamble: |
3 | .\" Standard preamble: |
4 | .\" ======================================================================== |
4 | .\" ======================================================================== |
5 | .de Sp \" Vertical space (when we can't use .PP) |
5 | .de Sp \" Vertical space (when we can't use .PP) |
6 | .if t .sp .5v |
6 | .if t .sp .5v |
… | |
… | |
131 | .\} |
131 | .\} |
132 | .rm #[ #] #H #V #F C |
132 | .rm #[ #] #H #V #F C |
133 | .\" ======================================================================== |
133 | .\" ======================================================================== |
134 | .\" |
134 | .\" |
135 | .IX Title "LIBEV 3" |
135 | .IX Title "LIBEV 3" |
136 | .TH LIBEV 3 "2021-01-11" "libev-4.33" "libev - high performance full featured event loop" |
136 | .TH LIBEV 3 "2023-05-15" "libev-4.33" "libev - high performance full featured event loop" |
137 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes |
137 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes |
138 | .\" way too many mistakes in technical documents. |
138 | .\" way too many mistakes in technical documents. |
139 | .if n .ad l |
139 | .if n .ad l |
140 | .nh |
140 | .nh |
141 | .SH "NAME" |
141 | .SH "NAME" |
… | |
… | |
801 | and is not embeddable, which would limit the usefulness of this backend |
801 | and is not embeddable, which would limit the usefulness of this backend |
802 | immensely. |
802 | immensely. |
803 | .ie n .IP """EVBACKEND_PORT"" (value 32, Solaris 10)" 4 |
803 | .ie n .IP """EVBACKEND_PORT"" (value 32, Solaris 10)" 4 |
804 | .el .IP "\f(CWEVBACKEND_PORT\fR (value 32, Solaris 10)" 4 |
804 | .el .IP "\f(CWEVBACKEND_PORT\fR (value 32, Solaris 10)" 4 |
805 | .IX Item "EVBACKEND_PORT (value 32, Solaris 10)" |
805 | .IX Item "EVBACKEND_PORT (value 32, Solaris 10)" |
806 | This uses the Solaris 10 event port mechanism. As with everything on Solaris, |
806 | This uses the Solaris 10 event port mechanism. As with everything on |
807 | it's really slow, but it still scales very well (O(active_fds)). |
807 | Solaris, it's really slow, but it still scales very well (O(active_fds)). |
808 | .Sp |
808 | .Sp |
809 | While this backend scales well, it requires one system call per active |
809 | While this backend scales well, it requires one system call per active |
810 | file descriptor per loop iteration. For small and medium numbers of file |
810 | file descriptor per loop iteration. For small and medium numbers of file |
811 | descriptors a \*(L"slow\*(R" \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR or \f(CW\*(C`EVBACKEND_POLL\*(C'\fR backend |
811 | descriptors a \*(L"slow\*(R" \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR or \f(CW\*(C`EVBACKEND_POLL\*(C'\fR backend |
812 | might perform better. |
812 | might perform better. |
… | |
… | |
1533 | .IP "bool ev_is_active (ev_TYPE *watcher)" 4 |
1533 | .IP "bool ev_is_active (ev_TYPE *watcher)" 4 |
1534 | .IX Item "bool ev_is_active (ev_TYPE *watcher)" |
1534 | .IX Item "bool ev_is_active (ev_TYPE *watcher)" |
1535 | Returns a true value iff the watcher is active (i.e. it has been started |
1535 | Returns a true value iff the watcher is active (i.e. it has been started |
1536 | and not yet been stopped). As long as a watcher is active you must not modify |
1536 | and not yet been stopped). As long as a watcher is active you must not modify |
1537 | it unless documented otherwise. |
1537 | it unless documented otherwise. |
|
|
1538 | .Sp |
|
|
1539 | Obviously, it is safe to call this on an active watcher, or actually any |
|
|
1540 | watcher that is initialised. |
1538 | .IP "bool ev_is_pending (ev_TYPE *watcher)" 4 |
1541 | .IP "bool ev_is_pending (ev_TYPE *watcher)" 4 |
1539 | .IX Item "bool ev_is_pending (ev_TYPE *watcher)" |
1542 | .IX Item "bool ev_is_pending (ev_TYPE *watcher)" |
1540 | Returns a true value iff the watcher is pending, (i.e. it has outstanding |
1543 | Returns a true value iff the watcher is pending, (i.e. it has outstanding |
1541 | events but its callback has not yet been invoked). As long as a watcher |
1544 | events but its callback has not yet been invoked). As long as a watcher |
1542 | is pending (but not active) you must not call an init function on it (but |
1545 | is pending (but not active) you must not call an init function on it (but |
1543 | \&\f(CW\*(C`ev_TYPE_set\*(C'\fR is safe), you must not change its priority, and you must |
1546 | \&\f(CW\*(C`ev_TYPE_set\*(C'\fR is safe), you must not change its priority, and you must |
1544 | make sure the watcher is available to libev (e.g. you cannot \f(CW\*(C`free ()\*(C'\fR |
1547 | make sure the watcher is available to libev (e.g. you cannot \f(CW\*(C`free ()\*(C'\fR |
1545 | it). |
1548 | it). |
|
|
1549 | .Sp |
|
|
1550 | It is safe to call this on any watcher in any state as long as it is |
|
|
1551 | initialised. |
1546 | .IP "callback ev_cb (ev_TYPE *watcher)" 4 |
1552 | .IP "callback ev_cb (ev_TYPE *watcher)" 4 |
1547 | .IX Item "callback ev_cb (ev_TYPE *watcher)" |
1553 | .IX Item "callback ev_cb (ev_TYPE *watcher)" |
1548 | Returns the callback currently set on the watcher. |
1554 | Returns the callback currently set on the watcher. |
1549 | .IP "ev_set_cb (ev_TYPE *watcher, callback)" 4 |
1555 | .IP "ev_set_cb (ev_TYPE *watcher, callback)" 4 |
1550 | .IX Item "ev_set_cb (ev_TYPE *watcher, callback)" |
1556 | .IX Item "ev_set_cb (ev_TYPE *watcher, callback)" |
… | |
… | |
1563 | from being executed (except for \f(CW\*(C`ev_idle\*(C'\fR watchers). |
1569 | from being executed (except for \f(CW\*(C`ev_idle\*(C'\fR watchers). |
1564 | .Sp |
1570 | .Sp |
1565 | If you need to suppress invocation when higher priority events are pending |
1571 | If you need to suppress invocation when higher priority events are pending |
1566 | you need to look at \f(CW\*(C`ev_idle\*(C'\fR watchers, which provide this functionality. |
1572 | you need to look at \f(CW\*(C`ev_idle\*(C'\fR watchers, which provide this functionality. |
1567 | .Sp |
1573 | .Sp |
1568 | You \fImust not\fR change the priority of a watcher as long as it is active or |
1574 | You \fImust not\fR change the priority of a watcher as long as it is active |
1569 | pending. |
1575 | or pending. Reading the priority with \f(CW\*(C`ev_priority\*(C'\fR is fine in any state. |
1570 | .Sp |
1576 | .Sp |
1571 | Setting a priority outside the range of \f(CW\*(C`EV_MINPRI\*(C'\fR to \f(CW\*(C`EV_MAXPRI\*(C'\fR is |
1577 | Setting a priority outside the range of \f(CW\*(C`EV_MINPRI\*(C'\fR to \f(CW\*(C`EV_MAXPRI\*(C'\fR is |
1572 | fine, as long as you do not mind that the priority value you query might |
1578 | fine, as long as you do not mind that the priority value you query might |
1573 | or might not have been clamped to the valid range. |
1579 | or might not have been clamped to the valid range. |
1574 | .Sp |
1580 | .Sp |
… | |
… | |
1593 | callback to be invoked, which can be accomplished with this function. |
1599 | callback to be invoked, which can be accomplished with this function. |
1594 | .IP "ev_feed_event (loop, ev_TYPE *watcher, int revents)" 4 |
1600 | .IP "ev_feed_event (loop, ev_TYPE *watcher, int revents)" 4 |
1595 | .IX Item "ev_feed_event (loop, ev_TYPE *watcher, int revents)" |
1601 | .IX Item "ev_feed_event (loop, ev_TYPE *watcher, int revents)" |
1596 | Feeds the given event set into the event loop, as if the specified event |
1602 | Feeds the given event set into the event loop, as if the specified event |
1597 | had happened for the specified watcher (which must be a pointer to an |
1603 | had happened for the specified watcher (which must be a pointer to an |
1598 | initialised but not necessarily started event watcher). Obviously you must |
1604 | initialised but not necessarily started event watcher, though it can be |
1599 | not free the watcher as long as it has pending events. |
1605 | active). Obviously you must not free the watcher as long as it has pending |
|
|
1606 | events. |
1600 | .Sp |
1607 | .Sp |
1601 | Stopping the watcher, letting libev invoke it, or calling |
1608 | Stopping the watcher, letting libev invoke it, or calling |
1602 | \&\f(CW\*(C`ev_clear_pending\*(C'\fR will clear the pending event, even if the watcher was |
1609 | \&\f(CW\*(C`ev_clear_pending\*(C'\fR will clear the pending event, even if the watcher was |
1603 | not started in the first place. |
1610 | not started in the first place. |
1604 | .Sp |
1611 | .Sp |
… | |
… | |
1625 | \&\f(CW\*(C`ev_TYPE_init\*(C'\fR again. |
1632 | \&\f(CW\*(C`ev_TYPE_init\*(C'\fR again. |
1626 | .IP "started/running/active" 4 |
1633 | .IP "started/running/active" 4 |
1627 | .IX Item "started/running/active" |
1634 | .IX Item "started/running/active" |
1628 | Once a watcher has been started with a call to \f(CW\*(C`ev_TYPE_start\*(C'\fR it becomes |
1635 | Once a watcher has been started with a call to \f(CW\*(C`ev_TYPE_start\*(C'\fR it becomes |
1629 | property of the event loop, and is actively waiting for events. While in |
1636 | property of the event loop, and is actively waiting for events. While in |
1630 | this state it cannot be accessed (except in a few documented ways), moved, |
1637 | this state it cannot be accessed (except in a few documented ways, such as |
1631 | freed or anything else \- the only legal thing is to keep a pointer to it, |
1638 | stoping it), moved, freed or anything else \- the only legal thing is to |
1632 | and call libev functions on it that are documented to work on active watchers. |
1639 | keep a pointer to it, and call libev functions on it that are documented |
|
|
1640 | to work on active watchers. |
|
|
1641 | .Sp |
|
|
1642 | As a rule of thumb, before accessing a member or calling any function on |
|
|
1643 | a watcher, it should be stopped (or freshly initialised). If that is not |
|
|
1644 | convenient, you can check the documentation for that function or member to |
|
|
1645 | see if it is safe to use on an active watcher. |
1633 | .IP "pending" 4 |
1646 | .IP "pending" 4 |
1634 | .IX Item "pending" |
1647 | .IX Item "pending" |
1635 | If a watcher is active and libev determines that an event it is interested |
1648 | If a watcher is active and libev determines that an event it is interested |
1636 | in has occurred (such as a timer expiring), it will become pending. It will |
1649 | in has occurred (such as a timer expiring), it will become pending. It |
1637 | stay in this pending state until either it is stopped or its callback is |
1650 | will stay in this pending state until either it is explicitly stopped or |
1638 | about to be invoked, so it is not normally pending inside the watcher |
1651 | its callback is about to be invoked, so it is not normally pending inside |
1639 | callback. |
1652 | the watcher callback. |
1640 | .Sp |
1653 | .Sp |
1641 | The watcher might or might not be active while it is pending (for example, |
1654 | Generally, the watcher might or might not be active while it is pending |
1642 | an expired non-repeating timer can be pending but no longer active). If it |
1655 | (for example, an expired non-repeating timer can be pending but no longer |
1643 | is stopped, it can be freely accessed (e.g. by calling \f(CW\*(C`ev_TYPE_set\*(C'\fR), |
1656 | active). If it is pending but not active, it can be freely accessed (e.g. |
1644 | but it is still property of the event loop at this time, so cannot be |
1657 | by calling \f(CW\*(C`ev_TYPE_set\*(C'\fR), but it is still property of the event loop at |
1645 | moved, freed or reused. And if it is active the rules described in the |
1658 | this time, so cannot be moved, freed or reused. And if it is active the |
1646 | previous item still apply. |
1659 | rules described in the previous item still apply. |
|
|
1660 | .Sp |
|
|
1661 | Explicitly stopping a watcher will also clear the pending state |
|
|
1662 | unconditionally, so it is safe to stop a watcher and then free it. |
1647 | .Sp |
1663 | .Sp |
1648 | It is also possible to feed an event on a watcher that is not active (e.g. |
1664 | It is also possible to feed an event on a watcher that is not active (e.g. |
1649 | via \f(CW\*(C`ev_feed_event\*(C'\fR), in which case it becomes pending without being |
1665 | via \f(CW\*(C`ev_feed_event\*(C'\fR), in which case it becomes pending without being |
1650 | active. |
1666 | active. |
1651 | .IP "stopped" 4 |
1667 | .IP "stopped" 4 |
… | |
… | |
4421 | .Sp |
4437 | .Sp |
4422 | For \f(CW\*(C`ev::embed\*(C'\fR watchers this method is called \f(CW\*(C`set_embed\*(C'\fR, to avoid |
4438 | For \f(CW\*(C`ev::embed\*(C'\fR watchers this method is called \f(CW\*(C`set_embed\*(C'\fR, to avoid |
4423 | clashing with the \f(CW\*(C`set (loop)\*(C'\fR method. |
4439 | clashing with the \f(CW\*(C`set (loop)\*(C'\fR method. |
4424 | .Sp |
4440 | .Sp |
4425 | For \f(CW\*(C`ev::io\*(C'\fR watchers there is an additional \f(CW\*(C`set\*(C'\fR method that acepts a |
4441 | For \f(CW\*(C`ev::io\*(C'\fR watchers there is an additional \f(CW\*(C`set\*(C'\fR method that acepts a |
4426 | new event mask only, and internally calls \f(CW\*(C`ev_io_modfify\*(C'\fR. |
4442 | new event mask only, and internally calls \f(CW\*(C`ev_io_modify\*(C'\fR. |
4427 | .IP "w\->start ()" 4 |
4443 | .IP "w\->start ()" 4 |
4428 | .IX Item "w->start ()" |
4444 | .IX Item "w->start ()" |
4429 | Starts the watcher. Note that there is no \f(CW\*(C`loop\*(C'\fR argument, as the |
4445 | Starts the watcher. Note that there is no \f(CW\*(C`loop\*(C'\fR argument, as the |
4430 | constructor already stores the event loop. |
4446 | constructor already stores the event loop. |
4431 | .IP "w\->start ([arguments])" 4 |
4447 | .IP "w\->start ([arguments])" 4 |