Integrate the Glib main loop into the libev event loop (C++)

Marc Lehmann schmorp at schmorp.de
Wed Jul 7 21:21:48 CEST 2021


On Wed, Jul 07, 2021 at 08:59:01AM +0200, Oleksandr Kozlov <aleks.a.kozlov at gmail.com> wrote:
> I've tried to replace std::map with std::vector, but this didn't help.
> Actually, I used std::list instead of std::vector, because ev::io has
> a private copy constructor, but we might need to resize a vector

Right, I ould have thought you'd use pointers as you'd have a similar problem
with std::map, but indeed, post-C+03 supports elements without copy
constructors in some circumstances. Anyway, speed is not your problem.

In any case, this is a guaranteed problöem that needs to be fixed in
soemway or another.

> By the way, it turned out that C-language implementation from EV::Glib
> behaves in the same way: also hangs.

Then I would check whether the glib watchers are actually legal.

> It worth to mention, that I've tried to create ev::idle to prevent the
> event loop
> from sleeping. This solves the problem with hanging, but the busy loop loads
> CPU for 100%.

I suspect the only realistic way forward is to understand why the program
is hanging. Hanging in the kernel call is unliekyl to be a problem with
libev, but more likely a problem with the glib program waiting for events
when that libev doesn't wait for.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the libev mailing list