Project

General

Profile

Misc #11500

[RFC] rename Queue to UnboundedQueue

Added by normalperson (Eric Wong) over 4 years ago.

Status:
Open
Priority:
Normal
Assignee:
-
[ruby-core:<unknown>]

Description

Then deprecate and warn on usage of "Queue"

Or maybe even call the new one "UnsafeQueue" :)

I think the name "Queue" causes too many people to use it without
knowing the consequences of unbounded memory growth and lack of backpressure.

In all cases I can think of, SizedQueue should be used instead of
current Queue since it will not cause a process to grow out-of-memory.

On the other hand, Ruby still has too many ways for users to shoot themselves in
the foot with unbounded memory growth:

  • using IO#read with no length argument
  • IO#gets on unknown data
  • Net::HTTP or open-uri to slurp a big file into memory
  • "SELECT" from a DB library with no LIMIT ... etc.

And having one extra guideline won't help less-experienced Rubyists at all...

Also available in: Atom PDF