Feature #8919

Queue as embedded class

Added by Koichi Sasada almost 2 years ago. Updated 8 months ago.

[ruby-core:57256]
Status:Assigned
Priority:Normal
Assignee:Koichi Sasada

Description

Queue class in lib/thread.rb (ext/thread/thread.c from Ruby 2.1) is easy and safe way to communicate between threads.

How about to include Queue class as embedded class to elaborate using Queue?

This proposal is not include ConditionVariable and SizedQueue.

patch.diff Magnifier - Queue Implementation as embedded class (15.7 KB) Masaki Matsushita, 11/27/2014 12:30 AM

History

#1 Updated by Koichi Sasada almost 2 years ago

Matz, how about it?

(no compatibility issue, we have an implementation)

#2 Updated by Hiroshi SHIBATA over 1 year ago

  • Target version changed from 2.1.0 to current: 2.2.0

#3 Updated by Yukihiro Matsumoto over 1 year ago

It's OK for 2.2.

Matz.

#4 Updated by Hiroshi SHIBATA 12 months ago

  • Assignee changed from Yukihiro Matsumoto to Koichi Sasada
  • Status changed from Open to Assigned

#5 Updated by Masaki Matsushita 8 months ago

How about the implementation in attached patch.diff?

#6 Updated by Koichi Sasada 8 months ago

Now, thread.rb is required from rubygems.

$ ./ruby -ve 'p Queue'
ruby 2.2.0dev (2014-11-20 trunk 48507) [x86_64-linux]
Thread::Queue

and

$ ./ruby --disable-gems -ve 'p Queue'
ruby 2.2.0dev (2014-11-20 trunk 48507) [x86_64-linux]
-e:1:in `<main>': uninitialized constant Queue (NameError)

What should we do?

#7 Updated by Nobuyoshi Nakada 8 months ago

By adding a line thread to ext/Setup file, thread.so can be statically linked to ruby (or libruby) now.

Also available in: Atom PDF