[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [paho-dev] non blocking sleep
- From: Greg Troxel <gdt@xxxxxxxxxx>
- Date: Mon, 07 Oct 2019 08:42:40 -0400
- Delivered-to: email@example.com
- Openpgp: id=098ED60E
- User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (berkeley-unix)
Carl Karsten <carl@xxxxxxxxxxxxxxxx> writes:
> Oh wait, that fires that off a thread and can return to paho's event loop,
> I have no idea what happens in the timer thread, but I trust this will all
> just work as needed. I hope.
Generally, the standard approach is to have a single event loop in a program.
Otherwise, you need locking between them, and if you aren't really clear
on how locking is done and why, you'll have trouble.
> I was thinking i needed my own event loop, which would need to play nice
> with paho, which I still only 1/2 understand how it can run in it's own
> thread if needed.
(Sorry, I am still on the "going to learn py-paho any day now" plan.)
> I think this is the first time I have really had to pay attention to
Beware that threads are 10x harder than you think they are, unless
you're a cranky old-school programmer who warns people about threads.
Basically, you have to get the locking right by design and code review,
because it's basically not debuggable since unsound code will usually
work. Although there is very recently "TSan" which probably makes
things much better.