Re: Critical sections with ev++.h

2020-07-19 Thread Marc Lehmann
On Fri, Jul 17, 2020 at 05:10:32PM +0200, Michele Santullo 
 wrote:
> notifications in separate threads and just print something to stdout when 
> they 
> occur. It's mostly working but I get occasionas crashes, which makes me think 
> it might be a concurrency issue.

Right, it also means you are not protecting calls to the same loop with a
mutex, which would get rid of the crashes.

> incredis/src/branch/master/src/async_connection.cpp#L122 that I was calling 
> ev_set_loop_release_cb(). If memory serves me right that was needed precisely 

ev_set_loop_release_cb won't get rid of the crashes for you, the purpose
of that call is so that you can release your mutex for longer times, i.e.
if another thread wants to acquire the mutex while libev is waiting in the
kernel it normally can't, because ev_run/ev_loop calls need to be also
protected via that mutex, and without ev_set_loop_release_cb this mutex
will be held while libev is polling the kernel.

> to solve some weird crash that I was getting, but in the C++ API I can't find 
> anything similar. Is it done is some other way in C++?

ev_set_loop_release_cb works fine in C++.

Note that, while ev++.h has some classes representing the main loop, only
the watcher classes are a) documented b) maintained and c) guaranteed to
some degree to stay. Everything else is undocumented, might be broken and
might go away or change incompatibly at any time.

> Also, small side question, is there an IRC channel for questions and 
> discussions about libev?

You can go to irc.schmorp.de #schmorpforge - I'll be there as user
schmorp, and some other users might also be able to help with libev. You
might have to /msg me to get my attention, though.

-- 
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


Critical sections with ev++.h

2020-07-19 Thread Michele Santullo
Hi, I'm trying to write a simple program in C++ that will get timer 
notifications in separate threads and just print something to stdout when they 
occur. It's mostly working but I get occasionas crashes, which makes me think 
it might be a concurrency issue.
In the past I already used libev, although using the C API directly, and going 
through my old code I see here https://alarmpi.no-ip.org/gitan/King_DuckZ/
incredis/src/branch/master/src/async_connection.cpp#L122 that I was calling 
ev_set_loop_release_cb(). If memory serves me right that was needed precisely 
to solve some weird crash that I was getting, but in the C++ API I can't find 
anything similar. Is it done is some other way in C++?

Also, small side question, is there an IRC channel for questions and 
discussions about libev?

Thanks,
Michele


signature.asc
Description: This is a digitally signed message part.
___
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev