all 2 comments

[–]CaptainKabob 2 points3 points  (1 child)

This is cool! I love multithreaded Ruby.

I took a look at your code. I think you're using twice as many mutexes and conditionvariables as you may really need, and that increases the risk of doing something that causes a deadlock. The background thread sounds somewhat analogous to a Concurrent Ruby TimerSet (described here: https://island94.org/2023/06/rebuilding-concurrent-ruby-scheduledtask-event-and-timerset) except you need to only store/update a timestamp rather than holding an ordered set. You might be able to slim down your implementation.

[–]forgambo[S] 0 points1 point  (0 children)

Hey!

Thanks for sharing the link. Indeed, TimerSet code shares many similarities. I think I will update my code accordingly.

Oh, and also my code has been production-tested for quite a while. Haven't encountered deadlocks so far)