ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.pod
(Generate patch)

Comparing libev/ev.pod (file contents):
Revision 1.49 by root, Tue Nov 27 08:20:42 2007 UTC vs.
Revision 1.50 by root, Tue Nov 27 10:59:11 2007 UTC

47(fractional) number of seconds since the (POSIX) epoch (somewhere near 47(fractional) number of seconds since the (POSIX) epoch (somewhere near
48the beginning of 1970, details are complicated, don't ask). This type is 48the beginning of 1970, details are complicated, don't ask). This type is
49called C<ev_tstamp>, which is what you should use too. It usually aliases 49called C<ev_tstamp>, which is what you should use too. It usually aliases
50to the C<double> type in C, and when you need to do any calculations on 50to the C<double> type in C, and when you need to do any calculations on
51it, you should treat it as such. 51it, you should treat it as such.
52
53 52
54=head1 GLOBAL FUNCTIONS 53=head1 GLOBAL FUNCTIONS
55 54
56These functions can be called anytime, even before initialising the 55These functions can be called anytime, even before initialising the
57library in any way. 56library in any way.
565received events. Callbacks of both watcher types can start and stop as 564received events. Callbacks of both watcher types can start and stop as
566many watchers as they want, and all of them will be taken into account 565many watchers as they want, and all of them will be taken into account
567(for example, a C<ev_prepare> watcher might start an idle watcher to keep 566(for example, a C<ev_prepare> watcher might start an idle watcher to keep
568C<ev_loop> from blocking). 567C<ev_loop> from blocking).
569 568
569=item C<EV_EMBED>
570
571The embedded event loop specified in the C<ev_embed> watcher needs attention.
572
573=item C<EV_FORK>
574
575The event loop has been resumed in the child process after fork (see
576C<ev_fork>).
577
570=item C<EV_ERROR> 578=item C<EV_ERROR>
571 579
572An unspecified error has occured, the watcher has been stopped. This might 580An unspecified error has occured, the watcher has been stopped. This might
573happen because the watcher could not be properly started because libev 581happen because the watcher could not be properly started because libev
574ran out of memory, a file descriptor was found to be closed or any other 582ran out of memory, a file descriptor was found to be closed or any other
1470The embedded event loop. 1478The embedded event loop.
1471 1479
1472=back 1480=back
1473 1481
1474 1482
1483=head2 C<ev_fork> - the audacity to resume the event loop after a fork
1484
1485Fork watchers are called when a C<fork ()> was detected (usually because
1486whoever is a good citizen cared to tell libev about it by calling
1487C<ev_default_fork> or C<ev_loop_fork>). The invocation is done before the
1488event loop blocks next and before C<ev_check> watchers are being called,
1489and only in the child after the fork. If whoever good citizen calling
1490C<ev_default_fork> cheats and calls it in the wrong process, the fork
1491handlers will be invoked, too, of course.
1492
1493=over 4
1494
1495=item ev_fork_init (ev_signal *, callback)
1496
1497Initialises and configures the fork watcher - it has no parameters of any
1498kind. There is a C<ev_fork_set> macro, but using it is utterly pointless,
1499believe me.
1500
1501=back
1502
1503
1475=head1 OTHER FUNCTIONS 1504=head1 OTHER FUNCTIONS
1476 1505
1477There are some other functions of possible interest. Described. Here. Now. 1506There are some other functions of possible interest. Described. Here. Now.
1478 1507
1479=over 4 1508=over 4
1663 : io (this, &myclass::io_cb), 1692 : io (this, &myclass::io_cb),
1664 idle (this, &myclass::idle_cb) 1693 idle (this, &myclass::idle_cb)
1665 { 1694 {
1666 io.start (fd, ev::READ); 1695 io.start (fd, ev::READ);
1667 } 1696 }
1697
1698
1699=head1 MACRO MAGIC
1700
1701Libev can be compiled with a variety of options, the most fundemantal is
1702C<EV_MULTIPLICITY>. This option determines wether (most) functions and
1703callbacks have an initial C<struct ev_loop *> argument.
1704
1705To make it easier to write programs that cope with either variant, the
1706following macros are defined:
1707
1708=over 4
1709
1710=item C<EV_A>, C<EV_A_>
1711
1712This provides the loop I<argument> for functions, if one is required ("ev
1713loop argument"). The C<EV_A> form is used when this is the sole argument,
1714C<EV_A_> is used when other arguments are following. Example:
1715
1716 ev_unref (EV_A);
1717 ev_timer_add (EV_A_ watcher);
1718 ev_loop (EV_A_ 0);
1719
1720It assumes the variable C<loop> of type C<struct ev_loop *> is in scope,
1721which is often provided by the following macro.
1722
1723=item C<EV_P>, C<EV_P_>
1724
1725This provides the loop I<parameter> for functions, if one is required ("ev
1726loop parameter"). The C<EV_P> form is used when this is the sole parameter,
1727C<EV_P_> is used when other parameters are following. Example:
1728
1729 // this is how ev_unref is being declared
1730 static void ev_unref (EV_P);
1731
1732 // this is how you can declare your typical callback
1733 static void cb (EV_P_ ev_timer *w, int revents)
1734
1735It declares a parameter C<loop> of type C<struct ev_loop *>, quite
1736suitable for use with C<EV_A>.
1737
1738=item C<EV_DEFAULT>, C<EV_DEFAULT_>
1739
1740Similar to the other two macros, this gives you the value of the default
1741loop, if multiple loops are supported ("ev loop default").
1742
1743=back
1744
1745Example: Declare and initialise a check watcher, working regardless of
1746wether multiple loops are supported or not.
1747
1748 static void
1749 check_cb (EV_P_ ev_timer *w, int revents)
1750 {
1751 ev_check_stop (EV_A_ w);
1752 }
1753
1754 ev_check check;
1755 ev_check_init (&check, check_cb);
1756 ev_check_start (EV_DEFAULT_ &check);
1757 ev_loop (EV_DEFAULT_ 0);
1758
1668 1759
1669=head1 EMBEDDING 1760=head1 EMBEDDING
1670 1761
1671Libev can (and often is) directly embedded into host 1762Libev can (and often is) directly embedded into host
1672applications. Examples of applications that embed it include the Deliantra 1763applications. Examples of applications that embed it include the Deliantra
1895=item EV_STAT_ENABLE 1986=item EV_STAT_ENABLE
1896 1987
1897If undefined or defined to be C<1>, then stat watchers are supported. If 1988If undefined or defined to be C<1>, then stat watchers are supported. If
1898defined to be C<0>, then they are not. 1989defined to be C<0>, then they are not.
1899 1990
1991=item EV_FORK_ENABLE
1992
1993If undefined or defined to be C<1>, then fork watchers are supported. If
1994defined to be C<0>, then they are not.
1995
1900=item EV_MINIMAL 1996=item EV_MINIMAL
1901 1997
1902If you need to shave off some kilobytes of code at the expense of some 1998If you need to shave off some kilobytes of code at the expense of some
1903speed, define this symbol to C<1>. Currently only used for gcc to override 1999speed, define this symbol to C<1>. Currently only used for gcc to override
1904some inlining decisions, saves roughly 30% codesize of amd64. 2000some inlining decisions, saves roughly 30% codesize of amd64.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines