queue with timeout

21 views
Skip to first unread message

Adrian Madrid

unread,
Sep 29, 2015, 4:34:14 PM9/29/15
to Concurrent Ruby
Anybody has a good implementation of a queue with pop timeout to share? Hopefully that uses concurrent?

Thanks in advance,


Adrian Madrid

Jerry D'Antonio

unread,
Sep 29, 2015, 4:40:50 PM9/29/15
to Adrian Madrid, Concurrent Ruby
Adrian,

In the next pre-release of concurrent-ruby (later tonight) I'll be pushing a new channel implementation. It will be part of the Edge gem. It will allow you to create a channel (behaves much like a queue) and set a timeout on each "take" operation. The implementation requires the use of a channel selector. The setup is a little more complex than a simple queue with a timeout on the "pop" method, but it's much more powerful.



I hope this helps!

Best regards,
Jerry


--
You received this message because you are subscribed to the Google Groups "Concurrent Ruby" group.
To unsubscribe from this group and stop receiving emails from it, send an email to concurrent-ru...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Adrian Madrid

unread,
Sep 29, 2015, 4:45:40 PM9/29/15
to Jerry D'Antonio, Concurrent Ruby
Interesting. I’ll dig into how it is working.

-- 
Adrian Madrid
Sent with Airmail

Adrian Madrid

unread,
Sep 30, 2015, 2:04:21 PM9/30/15
to Concurrent Ruby, aema...@gmail.com, jerry.d...@gmail.com
I have this first draft implementation:


It seems to be roughly working (need to write more tests) but I can seem to get the actual queue (busy) size. Any recommendations/critique?

Thanks in advance,


AEM

Jerry D'Antonio

unread,
Sep 30, 2015, 2:24:12 PM9/30/15
to Adrian Madrid, Concurrent Ruby
Adrian,

That looks really good. Thank you for giving it a try! I've made some comments on the gist.

Best regards,
Jerry

Adrian Madrid

unread,
Sep 30, 2015, 3:00:25 PM9/30/15
to Jerry D'Antonio, Concurrent Ruby
Replied to your comments there. I can’t figure out how to count how many items are in that buffered channel.


-- 
Adrian Madrid
Sent with Airmail

Jerry D'Antonio

unread,
Sep 30, 2015, 3:07:31 PM9/30/15
to Adrian Madrid, Concurrent Ruby
Oops. See notes on gist.

Best regards,
Jerry

Adrian Madrid

unread,
Sep 30, 2015, 3:31:21 PM9/30/15
to Jerry D'Antonio, Concurrent Ruby
Thought I could live without the actual size but it seems I cannot. Do you know how to get that now?

-- 
Adrian Madrid
Sent with Airmail

Reply all
Reply to author
Forward
0 new messages