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

Comparing libev/ev.pod (file contents):
Revision 1.6 by root, Mon Nov 12 08:12:14 2007 UTC vs.
Revision 1.7 by root, Mon Nov 12 08:16:02 2007 UTC

26Libev supports select, poll, the linux-specific epoll and the bsd-specific 26Libev supports select, poll, the linux-specific epoll and the bsd-specific
27kqueue mechanisms for file descriptor events, relative timers, absolute 27kqueue mechanisms for file descriptor events, relative timers, absolute
28timers with customised rescheduling, signal events, process status change 28timers with customised rescheduling, signal events, process status change
29events (related to SIGCHLD), and event watchers dealing with the event 29events (related to SIGCHLD), and event watchers dealing with the event
30loop mechanism itself (idle, prepare and check watchers). It also is quite 30loop mechanism itself (idle, prepare and check watchers). It also is quite
31fast (see a L<benchmark|http://libev.schmorp.de/bench.html> comparing it 31fast (see this L<benchmark|http://libev.schmorp.de/bench.html> comparing
32to libevent). 32it to libevent for example).
33 33
34=head1 CONVENTIONS 34=head1 CONVENTIONS
35 35
36Libev is very configurable. In this manual the default configuration 36Libev is very configurable. In this manual the default configuration
37will be described, which supports multiple event loops. For more info 37will be described, which supports multiple event loops. For more info
38about various configuraiton options please have a look at the file 38about various configuration options please have a look at the file
39F<README.embed> in the libev distribution. If libev was configured without 39F<README.embed> in the libev distribution. If libev was configured without
40support for multiple event loops, then all functions taking an initial 40support for multiple event loops, then all functions taking an initial
41argument of name C<loop> (which is always of type C<struct ev_loop *>) 41argument of name C<loop> (which is always of type C<struct ev_loop *>)
42will not have this argument. 42will not have this argument.
43 43
71not a problem. 71not a problem.
72 72
73=item ev_set_allocator (void *(*cb)(void *ptr, long size)) 73=item ev_set_allocator (void *(*cb)(void *ptr, long size))
74 74
75Sets the allocation function to use (the prototype is similar to the 75Sets the allocation function to use (the prototype is similar to the
76realloc function). It is used to allocate and free memory (no surprises 76realloc C function, the semantics are identical). It is used to allocate
77here). If it returns zero when memory needs to be allocated, the library 77and free memory (no surprises here). If it returns zero when memory
78might abort or take some potentially destructive action. The default is 78needs to be allocated, the library might abort or take some potentially
79your system realloc function. 79destructive action. The default is your system realloc function.
80 80
81You could override this function in high-availability programs to, say, 81You could override this function in high-availability programs to, say,
82free some memory if it cannot allocate memory, to use a special allocator, 82free some memory if it cannot allocate memory, to use a special allocator,
83or even to sleep a while and retry until some memory is available. 83or even to sleep a while and retry until some memory is available.
84 84
86 86
87Set the callback function to call on a retryable syscall error (such 87Set the callback function to call on a retryable syscall error (such
88as failed select, poll, epoll_wait). The message is a printable string 88as failed select, poll, epoll_wait). The message is a printable string
89indicating the system call or subsystem causing the problem. If this 89indicating the system call or subsystem causing the problem. If this
90callback is set, then libev will expect it to remedy the sitution, no 90callback is set, then libev will expect it to remedy the sitution, no
91matter what, when it returns. That is, libev will geenrally retry the 91matter what, when it returns. That is, libev will generally retry the
92requested operation, or, if the condition doesn't go away, do bad stuff 92requested operation, or, if the condition doesn't go away, do bad stuff
93(such as abort). 93(such as abort).
94 94
95=back 95=back
96 96
100types of such loops, the I<default> loop, which supports signals and child 100types of such loops, the I<default> loop, which supports signals and child
101events, and dynamically created loops which do not. 101events, and dynamically created loops which do not.
102 102
103If you use threads, a common model is to run the default event loop 103If you use threads, a common model is to run the default event loop
104in your main thread (or in a separate thrad) and for each thread you 104in your main thread (or in a separate thrad) and for each thread you
105create, you also create another event loop. Libev itself does no lockign 105create, you also create another event loop. Libev itself does no locking
106whatsoever, so if you mix calls to different event loops, make sure you 106whatsoever, so if you mix calls to the same event loop in different
107lock (this is usually a bad idea, though, even if done right). 107threads, make sure you lock (this is usually a bad idea, though, even if
108done correctly, because its hideous and inefficient).
108 109
109=over 4 110=over 4
110 111
111=item struct ev_loop *ev_default_loop (unsigned int flags) 112=item struct ev_loop *ev_default_loop (unsigned int flags)
112 113

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines