[ruby-core:124535] [Ruby Feature#21821] Add Stack and SizedStack classes
Issue #21821 has been updated by mame (Yusuke Endoh). Discussed at the dev meeting. No conclusion has been reached, but some opinions raised included: * Instead of introducing separate classes for each algorithm, how about introducing a generic container class under a more use-case-driven name like `Thread::Pool`? `Thread::Pool.new(:fifo)` or `Thread::Pool.new(:lifo)` could determine how to retrieve items, for example. (note: @matz didn't say his opinion about this, as I recall) * If we only need to add a method to retrieve items LIFO from Queue, returning to #21721, how about a method name that is clearly not orthodox, like `Queue#unpush`? @matz said he can compromise if a better name could be found. ---------------------------------------- Feature #21821: Add Stack and SizedStack classes https://bugs.ruby-lang.org/issues/21821#change-116103 * 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)
-
mame (Yusuke Endoh)