[ruby-core:124548] [Ruby Feature#21821] Add Stack and SizedStack classes
Issue #21821 has been updated by Eregon (Benoit Daloze). p8 (Petrik de Heus) wrote in #note-11:
The ConditionVariable in Puma 7's thread pool is causing issues in JRuby: [https://github.com/jruby/jruby/issues/9140](https://github.com/jruby/jruby/issues/9140)
I recall it was also causing issues in TruffleRuby back then hence my short attempt to remove it. But we fixed ConditionVariable since then and it seems to work fine now (though indeed there is the overhead of creating a `InterruptedException`, but the whole Java blocking/interruption is basically based on those so seems hard to fix and more of a JVM bug IMO). `ConditionVariable` are a very useful concurrency primitive, so I don't think it's productive in general to try to avoid them, better to optimize them since they are used in plenty of places.
So I thought about attempting to rewrite it without the ConditionVariable (but that is way out of my expertise and now I'm learning not possible with a SizedQueue).
Not possible is probably too strong, what I meant to say is when I looked at it and tried it there are some methods I couldn't implement with a SizedQueue, so the API back then and I think the API now has methods which are not implementable with a SizedQueue. ---------------------------------------- Feature #21821: Add Stack and SizedStack classes https://bugs.ruby-lang.org/issues/21821#change-116119 * 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)
-
Eregon (Benoit Daloze)