Thank you, Marc, for your input. This is my first time using such a
library, so I guess I don't get your point.

My main program should only receive a list of relevant events from inotify
and process them through a callback function of the main program. I want
libev++ to watch a directory of files and call the callback function as
soon as inotify gives at least one relevant event. And I don't want libev++
to block my main program, that's why I tried to use it with NOWAIT.

Am I doing it totally wrong? Is libev++ a right tool for the task?

If I add ev_run(EV_A_ 0); to engage_watcher() I get use of undeclared
identifier 'loop'. If I also add ev::default_loop loop; then I can build
and run the program but it gets blocked until I change a file in the
directory being watched. And even after that the program's window doesn't
show up.

If I replace 0 with EVRUN_NOWAIT then the window shows up but io_callback()
is never invoked again.

How can I get it working?

On Mon, Oct 12, 2020 at 2:51 PM Marc Lehmann <schm...@schmorp.de> wrote:

> On Sun, Oct 11, 2020 at 04:51:09PM +0500, rustahm <rust...@gmail.com>
> wrote:
> > Please find attached the source code. Could anyone explain why the
> callback
> > is never invoked when I do change the files?
>
> You probably never call ev's mainloop: you only call ev::run once with
> NOWAIT, so unless any change happens before that call, libev code is never
> invoked and therefore does not have a chance of calling your callback.
>
> You would need to put something like ev_run (EV_A_ 0) into your main
> program
> (which you haven't shown).
>
> Also, ev::get_default_loop() (and .run) is internal undocumented
> functionality which you should not call if you want your program to
> continue to work with future versions.
>
> --
>                 The choice of a       Deliantra, the free code+content
> MORPG
>       -----==-     _GNU_              http://www.deliantra.net
>       ----==-- _       generation
>       ---==---(_)__  __ ____  __      Marc Lehmann
>       --==---/ / _ \/ // /\ \/ /      schm...@schmorp.de
>       -=====/_/_//_/\_,_/ /_/\_\
>
_______________________________________________
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev

Reply via email to