… | |
… | |
3456 | |
3456 | |
3457 | This section explains some common idioms that are not immediately |
3457 | This section explains some common idioms that are not immediately |
3458 | obvious. Note that examples are sprinkled over the whole manual, and this |
3458 | obvious. Note that examples are sprinkled over the whole manual, and this |
3459 | section only contains stuff that wouldn't fit anywhere else. |
3459 | section only contains stuff that wouldn't fit anywhere else. |
3460 | |
3460 | |
3461 | =over 4 |
3461 | =head2 MODEL/NESTED EVENT LOOP INVOCATIONS AND EXIT CONDITIONS |
3462 | |
|
|
3463 | =item Model/nested event loop invocations and exit conditions. |
|
|
3464 | |
3462 | |
3465 | Often (especially in GUI toolkits) there are places where you have |
3463 | Often (especially in GUI toolkits) there are places where you have |
3466 | I<modal> interaction, which is most easily implemented by recursively |
3464 | I<modal> interaction, which is most easily implemented by recursively |
3467 | invoking C<ev_run>. |
3465 | invoking C<ev_run>. |
3468 | |
3466 | |
… | |
… | |
3497 | exit_main_loop = 1; |
3495 | exit_main_loop = 1; |
3498 | |
3496 | |
3499 | // exit both |
3497 | // exit both |
3500 | exit_main_loop = exit_nested_loop = 1; |
3498 | exit_main_loop = exit_nested_loop = 1; |
3501 | |
3499 | |
3502 | =item Thread locking example |
3500 | =head2 THREAD LOCKING EXAMPLE |
3503 | |
3501 | |
3504 | Here is a fictitious example of how to run an event loop in a different |
3502 | Here is a fictitious example of how to run an event loop in a different |
3505 | thread than where callbacks are being invoked and watchers are |
3503 | thread than where callbacks are being invoked and watchers are |
3506 | created/added/removed. |
3504 | created/added/removed. |
3507 | |
3505 | |
… | |
… | |
4636 | default loop and triggering an C<ev_async> watcher from the default loop |
4634 | default loop and triggering an C<ev_async> watcher from the default loop |
4637 | watcher callback into the event loop interested in the signal. |
4635 | watcher callback into the event loop interested in the signal. |
4638 | |
4636 | |
4639 | =back |
4637 | =back |
4640 | |
4638 | |
4641 | See also L<Thread locking example>. |
4639 | See also L<THREAD LOCKING EXAMPLE>. |
4642 | |
4640 | |
4643 | =head3 COROUTINES |
4641 | =head3 COROUTINES |
4644 | |
4642 | |
4645 | Libev is very accommodating to coroutines ("cooperative threads"): |
4643 | Libev is very accommodating to coroutines ("cooperative threads"): |
4646 | libev fully supports nesting calls to its functions from different |
4644 | libev fully supports nesting calls to its functions from different |