From: Aaron Patterson Date: 2012-04-14T11:25:01+09:00 Subject: [ruby-core:44357] Re: [ruby-trunk - Feature #6293][Assigned] new queue / blocking queues --MfFXiAuoTsnnDAfZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Apr 14, 2012 at 10:58:12AM +0900, mame (Yusuke Endoh) wrote: >=20 > Issue #6293 has been updated by mame (Yusuke Endoh). >=20 > Status changed from Open to Assigned > Assignee set to matz (Yukihiro Matsumoto) >=20 > Hello, >=20 > 2012/4/14 tenderlovemaking (Aaron Patterson) : > > I'd like to add new Queue objects to ruby. >=20 > I bet matz does not accept it because there is no good reason. > Why don't you extend the traditional Queue class? I could, but I think the changes I want would add too much complexity to the traditional Queue class. We have to add branching code for every method that could block / not-block. Not to mention users must pass the magical true | false to indicate if they want blocking or non-blocking behavior. For example: queue.pop(true) # does "true" mean I enable blocking? queue.pop(false) # does "false" mean I disable blocking? It seems confusing to me, especially given the *actual* api with twists your brain with a double negative (from thread.rb): def pop(non_block=3Dfalse) ... end So calling pop() means we're doing a not not blocking call. :( > > * include Enumerable >=20 > The semantics is not trivial. See the discussion in #4589. I've read #4589. I don't think it's that much of a problem. Other languages[1] include enumerable type behavior in their queues, and consistency is not guaranteed. 1. http://docs.oracle.com/javase/6/docs/api/java/util/Queue.html#methods_i= nherited_from_class_java.util.Collection --=20 Aaron Patterson http://tenderlovemaking.com/ --MfFXiAuoTsnnDAfZ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iQEcBAEBAgAGBQJPiOAFAAoJEJUxcLy0/6/GjcUH/3ey4of2ybgSd16/49kF39bY G+PYFMIPjZ7WizSjtaY0T3CZxxNzPelP+FsIySpujPN4LlKDDmqQNmuq6d2MN30T /BnwoTXNVLATj1VnJBBiy16x1XpP90fFW7J4kdrdyMvPR0m+KIPxnea7rfv7r4Yr e3Pmtdg4dShNBcJIH4UINgBtOKlVKcb0yu8gVa75LJQBYtxhLWHSTIkTNvHsk076 ztNNDa3XgmeFpVb3qze7bvA/B4E5TLC37NtIvSmyvoVk9+sTIwamJvsPzEhVRON5 L/ss1Pz7BNAxmLYG9GlbUcBjXDcOcBN3YmrUrwPtgOD9XzQH5lJnbRGXKtk6vVs= =TsKY -----END PGP SIGNATURE----- --MfFXiAuoTsnnDAfZ--