What is the best way of choosing between mutex_lock and mutex_trylock?
What does mutex_lock do when the mutex is already locked? does it wait?
I looked at the ‘collect’ example and there is no mention of mutex_trylock. Is that on purpose?
thanks for the response, sorry for my delay in responding
I did a little test and yes, the mutex_lock sleeps the current thread. Another thread can still unlock it.
curious: what is your recipe for delaying the message inside the external?
FWIW I also use lightweight thread sync stuff based on atomic operations a lot of the time, including when I need to wait till the lock is free. In this case you can spin on a while loop until it is free or similar . The thread will be consuming cycles, but that is often IMHO preferable to sleeping threads for short periods in real-time contexts…
interesting, thanks guys.
alex, why is in your opinion spinning on a while loop preferred to sleeping a thread?
isn’t that basically the same thing? or do I miss something.
C74 RSS Feed | © Copyright Cycling '74