All works now,
Great!
I love clean solutions!
Me too :)
In the next AOO version I might use sync::shared_spinlock for the update
lock resp. provide a compile time option to choose between mutex and
spinlock. The reason is that a mutex try-lock is not guaranteed to be
realtime safe because the *unlock* operation might have to wake up
waiting threads, which requires calling into the kernel.
(In practice, I think unlocking a mutex should be comparable to
signalling a semaphore, which is a pretty common thing in audio apps.
Nevertheless, I want to give people a 100% realtime safe option.)
Christof
On 8/13/2026 5:27 PM, Wolfgang Gaggl via Pd-list wrote:
As I said, you just need to replace the shared_mutex with a shared_spinlock.
Yes, that was the best solution all along!
In sink.hpp
#if defined(__sgi) && defined(__mips__)
using sink_update_lock = sync::shared_spinlock;
#else
using sink_update_lock = sync::shared_mutex;
#endif
And further down:
private:
using shared_lock = sync::shared_lock<sink_update_lock>; //
sink_update_lock, not shared_mutex
using unique_lock = sync::unique_lock<sink_update_lock>;
using scoped_lock = sync::scoped_lock<sink_update_lock>;
using scoped_shared_lock = sync::scoped_shared_lock<sink_update_lock>;
In source.hpp
#if defined(__sgi) && defined(__mips__)
using source_update_lock = sync::shared_spinlock;
#else
using source_update_lock = sync::shared_mutex;
#endif
and further down:
private:
using shared_lock = sync::shared_lock<source_update_lock>; //
source_update_lock, not shared_mutex
using unique_lock = sync::unique_lock<source_update_lock>;
using scoped_lock = sync::scoped_lock<source_update_lock>;
using scoped_shared_lock = sync::scoped_shared_lock<source_update_lock>;
using scoped_spinlock = sync::scoped_lock<sync::spinlock>;
Or maybe just once in sync.hpp...
No changes in source.cpp or sink.cpp needed (even the try_to_lock works fine as
is).
All works now, I love clean solutions!
Thank you!
---
[email protected] - the Pure Data mailinglist
https://lists.iem.at/hyperkitty/list/[email protected]/message/HSGOXJKTTKJ6D3G4WPQFK2KLXD5S3FSJ/
To unsubscribe send an email to [email protected] mailing list
UNSUBSCRIBE and account-management -> https://lists.iem.at/
---
[email protected] - the Pure Data mailinglist
https://lists.iem.at/hyperkitty/list/[email protected]/message/QFDZWY4R5TKDFP7MV7N4KUKB66IERB3A/
To unsubscribe send an email to [email protected] mailing list
UNSUBSCRIBE and account-management -> https://lists.iem.at/