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

Comparing libev/ev.pod (file contents):
Revision 1.358 by sf-exg, Tue Jan 11 08:43:48 2011 UTC vs.
Revision 1.361 by root, Sun Jan 23 18:53:06 2011 UTC

441when you want to receive them. 441when you want to receive them.
442 442
443This behaviour is useful when you want to do your own signal handling, or 443This behaviour is useful when you want to do your own signal handling, or
444want to handle signals only in specific threads and want to avoid libev 444want to handle signals only in specific threads and want to avoid libev
445unblocking the signals. 445unblocking the signals.
446
447It's also required by POSIX in a threaded program, as libev calls
448C<sigprocmask>, whose behaviour is officially unspecified.
446 449
447This flag's behaviour will become the default in future versions of libev. 450This flag's behaviour will become the default in future versions of libev.
448 451
449=item C<EVBACKEND_SELECT> (value 1, portable select backend) 452=item C<EVBACKEND_SELECT> (value 1, portable select backend)
450 453
1375 1378
1376Before a watcher can be registered with the event looop it has to be 1379Before a watcher can be registered with the event looop it has to be
1377initialised. This can be done with a call to C<ev_TYPE_init>, or calls to 1380initialised. This can be done with a call to C<ev_TYPE_init>, or calls to
1378C<ev_init> followed by the watcher-specific C<ev_TYPE_set> function. 1381C<ev_init> followed by the watcher-specific C<ev_TYPE_set> function.
1379 1382
1380In this state it is simply some block of memory that is suitable for use 1383In this state it is simply some block of memory that is suitable for
1381in an event loop. It can be moved around, freed, reused etc. at will. 1384use in an event loop. It can be moved around, freed, reused etc. at
1385will - as long as you either keep the memory contents intact, or call
1386C<ev_TYPE_init> again.
1382 1387
1383=item started/running/active 1388=item started/running/active
1384 1389
1385Once a watcher has been started with a call to C<ev_TYPE_start> it becomes 1390Once a watcher has been started with a call to C<ev_TYPE_start> it becomes
1386property of the event loop, and is actively waiting for events. While in 1391property of the event loop, and is actively waiting for events. While in
1414latter will clear any pending state the watcher might be in, regardless 1419latter will clear any pending state the watcher might be in, regardless
1415of whether it was active or not, so stopping a watcher explicitly before 1420of whether it was active or not, so stopping a watcher explicitly before
1416freeing it is often a good idea. 1421freeing it is often a good idea.
1417 1422
1418While stopped (and not pending) the watcher is essentially in the 1423While stopped (and not pending) the watcher is essentially in the
1419initialised state, that is it can be reused, moved, modified in any way 1424initialised state, that is, it can be reused, moved, modified in any way
1420you wish. 1425you wish (but when you trash the memory block, you need to C<ev_TYPE_init>
1426it again).
1421 1427
1422=back 1428=back
1423 1429
1424=head2 WATCHER PRIORITY MODELS 1430=head2 WATCHER PRIORITY MODELS
1425 1431
2300=head3 The special problem of inheritance over fork/execve/pthread_create 2306=head3 The special problem of inheritance over fork/execve/pthread_create
2301 2307
2302Both the signal mask (C<sigprocmask>) and the signal disposition 2308Both the signal mask (C<sigprocmask>) and the signal disposition
2303(C<sigaction>) are unspecified after starting a signal watcher (and after 2309(C<sigaction>) are unspecified after starting a signal watcher (and after
2304stopping it again), that is, libev might or might not block the signal, 2310stopping it again), that is, libev might or might not block the signal,
2305and might or might not set or restore the installed signal handler. 2311and might or might not set or restore the installed signal handler (but
2312see C<EVFLAG_NOSIGMASK>).
2306 2313
2307While this does not matter for the signal disposition (libev never 2314While this does not matter for the signal disposition (libev never
2308sets signals to C<SIG_IGN>, so handlers will be reset to C<SIG_DFL> on 2315sets signals to C<SIG_IGN>, so handlers will be reset to C<SIG_DFL> on
2309C<execve>), this matters for the signal mask: many programs do not expect 2316C<execve>), this matters for the signal mask: many programs do not expect
2310certain signals to be blocked. 2317certain signals to be blocked.
3504 exit_main_loop = exit_nested_loop = 1; 3511 exit_main_loop = exit_nested_loop = 1;
3505 3512
3506=head2 THREAD LOCKING EXAMPLE 3513=head2 THREAD LOCKING EXAMPLE
3507 3514
3508Here is a fictitious example of how to run an event loop in a different 3515Here is a fictitious example of how to run an event loop in a different
3509thread than where callbacks are being invoked and watchers are 3516thread from where callbacks are being invoked and watchers are
3510created/added/removed. 3517created/added/removed.
3511 3518
3512For a real-world example, see the C<EV::Loop::Async> perl module, 3519For a real-world example, see the C<EV::Loop::Async> perl module,
3513which uses exactly this technique (which is suited for many high-level 3520which uses exactly this technique (which is suited for many high-level
3514languages). 3521languages).

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines