… | |
… | |
3633 | int exit_main_loop = 0; |
3633 | int exit_main_loop = 0; |
3634 | |
3634 | |
3635 | while (!exit_main_loop) |
3635 | while (!exit_main_loop) |
3636 | ev_run (EV_DEFAULT_ EVRUN_ONCE); |
3636 | ev_run (EV_DEFAULT_ EVRUN_ONCE); |
3637 | |
3637 | |
3638 | // in a model watcher |
3638 | // in a modal watcher |
3639 | int exit_nested_loop = 0; |
3639 | int exit_nested_loop = 0; |
3640 | |
3640 | |
3641 | while (!exit_nested_loop) |
3641 | while (!exit_nested_loop) |
3642 | ev_run (EV_A_ EVRUN_ONCE); |
3642 | ev_run (EV_A_ EVRUN_ONCE); |
3643 | |
3643 | |
… | |
… | |
3823 | switch_to (libev_coro); |
3823 | switch_to (libev_coro); |
3824 | } |
3824 | } |
3825 | |
3825 | |
3826 | That basically suspends the coroutine inside C<wait_for_event> and |
3826 | That basically suspends the coroutine inside C<wait_for_event> and |
3827 | continues the libev coroutine, which, when appropriate, switches back to |
3827 | continues the libev coroutine, which, when appropriate, switches back to |
3828 | this or any other coroutine. I am sure if you sue this your own :) |
3828 | this or any other coroutine. |
3829 | |
3829 | |
3830 | You can do similar tricks if you have, say, threads with an event queue - |
3830 | You can do similar tricks if you have, say, threads with an event queue - |
3831 | instead of storing a coroutine, you store the queue object and instead of |
3831 | instead of storing a coroutine, you store the queue object and instead of |
3832 | switching to a coroutine, you push the watcher onto the queue and notify |
3832 | switching to a coroutine, you push the watcher onto the queue and notify |
3833 | any waiters. |
3833 | any waiters. |
… | |
… | |
4652 | With an intelligent-enough linker (gcc+binutils are intelligent enough |
4652 | With an intelligent-enough linker (gcc+binutils are intelligent enough |
4653 | when you use C<-Wl,--gc-sections -ffunction-sections>) functions unused by |
4653 | when you use C<-Wl,--gc-sections -ffunction-sections>) functions unused by |
4654 | your program might be left out as well - a binary starting a timer and an |
4654 | your program might be left out as well - a binary starting a timer and an |
4655 | I/O watcher then might come out at only 5Kb. |
4655 | I/O watcher then might come out at only 5Kb. |
4656 | |
4656 | |
|
|
4657 | =item EV_API_STATIC |
|
|
4658 | |
|
|
4659 | If this symbol is defined (by default it is not), then all identifiers |
|
|
4660 | will have static linkage. This means that libev will not export any |
|
|
4661 | identifiers, and you cannot link against libev anymore. This can be useful |
|
|
4662 | when you embed libev, only want to use libev functions in a single file, |
|
|
4663 | and do not want its identifiers to be visible. |
|
|
4664 | |
|
|
4665 | To use this, define C<EV_API_STATIC> and include F<ev.c> in the file that |
|
|
4666 | wants to use libev. |
|
|
4667 | |
4657 | =item EV_AVOID_STDIO |
4668 | =item EV_AVOID_STDIO |
4658 | |
4669 | |
4659 | If this is set to C<1> at compiletime, then libev will avoid using stdio |
4670 | If this is set to C<1> at compiletime, then libev will avoid using stdio |
4660 | functions (printf, scanf, perror etc.). This will increase the code size |
4671 | functions (printf, scanf, perror etc.). This will increase the code size |
4661 | somewhat, but if your program doesn't otherwise depend on stdio and your |
4672 | somewhat, but if your program doesn't otherwise depend on stdio and your |