Koichi Sasada ef2bb61018 Ractor::Port
* Added `Ractor::Port`
  * `Ractor::Port#receive` (support multi-threads)
  * `Rcator::Port#close`
  * `Ractor::Port#closed?`
* Added some methods
  * `Ractor#join`
  * `Ractor#value`
  * `Ractor#monitor`
  * `Ractor#unmonitor`
* Removed some methods
  * `Ractor#take`
  * `Ractor.yield`
* Change the spec
  * `Racotr.select`

You can wait for multiple sequences of messages with `Ractor::Port`.

```ruby
ports = 3.times.map{ Ractor::Port.new }
ports.map.with_index do |port, ri|
  Ractor.new port,ri do |port, ri|
    3.times{|i| port << "r#{ri}-#{i}"}
  end
end

p ports.each{|port| pp 3.times.map{port.receive}}

```

In this example, we use 3 ports, and 3 Ractors send messages to them respectively.
We can receive a series of messages from each port.

You can use `Ractor#value` to get the last value of a Ractor's block:

```ruby
result = Ractor.new do
  heavy_task()
end.value
```

You can wait for the termination of a Ractor with `Ractor#join` like this:

```ruby
Ractor.new do
  some_task()
end.join
```

`#value` and `#join` are similar to `Thread#value` and `Thread#join`.

To implement `#join`, `Ractor#monitor` (and `Ractor#unmonitor`) is introduced.

This commit changes `Ractor.select()` method.
It now only accepts ports or Ractors, and returns when a port receives a message or a Ractor terminates.

We removes `Ractor.yield` and `Ractor#take` because:
* `Ractor::Port` supports most of similar use cases in a simpler manner.
* Removing them significantly simplifies the code.

We also change the internal thread scheduler code (thread_pthread.c):
* During barrier synchronization, we keep the `ractor_sched` lock to avoid deadlocks.
  This lock is released by `rb_ractor_sched_barrier_end()`
  which is called at the end of operations that require the barrier.
* fix potential deadlock issues by checking interrupts just before setting UBF.

https://bugs.ruby-lang.org/issues/21262
2025-05-31 04:01:33 +09:00
2025-05-31 04:01:33 +09:00
2025-05-30 18:44:28 +09:00
2025-05-27 12:45:24 +02:00
2025-05-31 04:01:33 +09:00
2025-04-22 15:34:21 +09:00
2025-05-20 09:56:31 -07:00
2025-05-31 04:01:33 +09:00
2025-05-28 11:44:07 -04:00
2025-01-20 15:48:08 +01:00
2025-05-01 16:58:06 -07:00
2025-05-11 07:07:10 +09:00
2025-01-03 11:42:53 -05:00
2025-03-08 18:26:40 +09:00
2025-05-11 23:32:50 +09:00
2025-05-31 04:01:33 +09:00
2025-05-15 17:48:40 +09:00
2025-04-19 22:02:10 +09:00
2025-04-09 19:13:58 +09:00
2025-01-02 11:03:04 -05:00
2025-04-25 13:46:05 -07:00
2025-05-20 22:12:58 +09:00
2025-05-11 23:32:50 +09:00
2025-05-11 23:32:50 +09:00
2025-05-11 23:32:50 +09:00
2025-04-22 01:49:41 +09:00
2025-04-19 22:02:10 +09:00
2025-05-11 23:32:50 +09:00
2025-05-28 11:44:07 -04:00
2025-05-31 04:01:33 +09:00
2025-02-13 08:53:02 +09:00
GPL
2025-05-25 15:22:43 +09:00
2025-01-24 10:44:24 -05:00
2025-05-11 23:32:50 +09:00
2025-05-11 23:32:50 +09:00
2025-03-28 07:24:52 +09:00
2025-05-15 17:48:40 +09:00
2025-05-25 15:22:43 +09:00
2025-05-11 23:32:50 +09:00
2025-05-25 15:22:43 +09:00
2025-03-08 18:26:40 +09:00
2025-01-09 19:24:27 +09:00
2025-01-30 18:19:53 +09:00
2025-05-28 11:44:07 -04:00
2025-05-25 15:22:43 +09:00
2025-05-31 04:01:33 +09:00
2025-05-31 04:01:33 +09:00
2025-05-31 04:01:33 +09:00
2025-05-31 04:01:33 +09:00
2025-04-09 19:13:58 +09:00
2025-05-15 17:48:40 +09:00
2025-05-15 17:48:40 +09:00
2025-05-15 17:48:40 +09:00
2025-05-11 23:32:50 +09:00
2025-03-08 18:26:40 +09:00
2025-05-28 12:39:21 +02:00
2025-05-20 09:56:31 -07:00
2025-05-22 10:17:46 -04:00
2025-04-19 22:02:10 +09:00
2025-05-31 04:01:33 +09:00
2025-05-31 04:01:33 +09:00
2025-05-31 04:01:33 +09:00
2025-05-31 04:01:33 +09:00
2025-05-31 04:01:33 +09:00
2025-03-31 16:56:29 +02:00
2025-02-23 10:37:36 +09:00
2025-04-18 21:52:57 +09:00
2025-05-28 12:39:21 +02:00
2025-05-31 04:01:33 +09:00
2025-05-15 17:48:40 +09:00
2025-05-31 04:01:33 +09:00
2025-05-31 04:01:33 +09:00
2025-04-27 15:47:30 +09:00
2025-05-31 04:01:33 +09:00
2025-05-26 02:44:58 +00:00
2025-05-26 02:44:58 +00:00

Actions Status: MinGW Actions Status: Ubuntu Actions Status: Windows Travis Status

What is Ruby?

Ruby is an interpreted object-oriented programming language often used for web development. It also offers many scripting features to process plain text and serialized files, or manage system tasks. It is simple, straightforward, and extensible.

Features of Ruby

  • Simple Syntax
  • Normal Object-oriented Features (e.g. class, method calls)
  • Advanced Object-oriented Features (e.g. mix-in, singleton-method)
  • Operator Overloading
  • Exception Handling
  • Iterators and Closures
  • Garbage Collection
  • Dynamic Loading of Object Files (on some architectures)
  • Highly Portable (works on many Unix-like/POSIX compatible platforms as well as Windows, macOS, etc.) cf. https://docs.ruby-lang.org/en/master/maintainers_md.html#label-Platform+Maintainers

How to get Ruby

For a complete list of ways to install Ruby, including using third-party tools like rvm, see:

https://www.ruby-lang.org/en/downloads/

You can download release packages and the snapshot of the repository. If you want to download whole versions of Ruby, please visit https://www.ruby-lang.org/en/downloads/releases/.

Download with Git

The mirror of the Ruby source tree can be checked out with the following command:

$ git clone https://github.com/ruby/ruby.git

There are some other branches under development. Try the following command to see the list of branches:

$ git ls-remote https://github.com/ruby/ruby.git

You may also want to use https://git.ruby-lang.org/ruby.git (actual master of Ruby source) if you are a committer.

How to build

See Building Ruby

Ruby home page

https://www.ruby-lang.org/

Documentation

Mailing list

There is a mailing list to discuss Ruby. To subscribe to this list, please send the following phrase:

join

in the mail subject (not body) to the address ruby-talk-request@ml.ruby-lang.org.

Copying

See the file COPYING.

Feedback

Questions about the Ruby language can be asked on the Ruby-Talk mailing list or on websites like https://stackoverflow.com.

Bugs should be reported at https://bugs.ruby-lang.org. Read "Reporting Issues" for more information.

Contributing

See "Contributing to Ruby", which includes setup and build instructions.

The Author

Ruby was originally designed and developed by Yukihiro Matsumoto (Matz) in 1995.

matz@ruby-lang.org

Description
Languages
Ruby 58.9%
C 29.5%
Rust 6.1%
C++ 2.9%
Yacc 0.9%
Other 1.6%