[ruby-core:124516] [Ruby Feature#21821] Add Stack and SizedStack classes
Issue #21821 has been updated by p8 (Petrik de Heus). Eregon (Benoit Daloze) wrote in #note-9:
It reminds me when I once tried to replace the queue in Puma's [thread pool](https://github.com/puma/puma/blob/main/lib/puma/thread_pool.rb) with a SizedQueue to remove the extra ConditionVariable & Mutex, but it's not possible, it does things that SizedQueue can't do.
The ConditionVariable in Puma 7's thread pool is causing issues in JRuby: https://github.com/jruby/jruby/issues/9140 Sequel's [timed_queue](https://github.com/jeremyevans/sequel/blob/4293be3cb8dbb50992e2ee7c55415928e...) avoids the ConditionalVariable with [big improvements for some](https://github.com/jeremyevans/sequel/discussions/2207), but I'm not sure that can be applied to Puma. ---------------------------------------- Feature #21821: Add Stack and SizedStack classes https://bugs.ruby-lang.org/issues/21821#change-116076 * Author: byroot (Jean Boussier) * Status: Open * Target version: 4.1 ---------------------------------------- ### Context `Queue` and `SizedQueue` are very useful and performant constructs, however they only allow for FIFO queues. Some use cases do call for LIFO queues AKA stacks. For instance, in the case of connection pool, it's often preferable to use a stack. ### Feature I'd like to introduce `Stack` and `SizedStack` classes, to mirror `Queue` and `SizedQueue`. They'd have exactly the same method and behavior at the exception of dequeuing order. ### Thread namespace? Currently `Queue` and `SizedQueue` are technically defined under `Thread` and aliased in `Object`. I wonder if that's something we should do for `Stack` too, or just some historical thing we shouldn't perpetuate. -- https://bugs.ruby-lang.org/
participants (1)
-
p8 (Petrik de Heus)