<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/internal/thread.h, branch v4.0.2</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>Fewer calls to `GET_EC()` and `GET_THREAD()` (#15506)</title>
<updated>2025-12-12T19:47:43+00:00</updated>
<author>
<name>Luke Gruber</name>
<email>luke.gruber@shopify.com</email>
</author>
<published>2025-12-12T19:47:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=3add3db797c4216423fdaa4bef6e2ee3c7630303'/>
<id>3add3db797c4216423fdaa4bef6e2ee3c7630303</id>
<content type='text'>
The changes are to `io.c` and `thread.c`.
I changed the API of 2 exported thread functions from `internal/thread.h` that
didn't look like they had any use in C extensions:

* rb_thread_wait_for_single_fd
* rb_thread_io_wait

I didn't change the following exported internal function because it's
used in C extensions:

* rb_thread_fd_select

I added a comment to note that this function, although internal, is used
in C extensions.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The changes are to `io.c` and `thread.c`.
I changed the API of 2 exported thread functions from `internal/thread.h` that
didn't look like they had any use in C extensions:

* rb_thread_wait_for_single_fd
* rb_thread_io_wait

I didn't change the following exported internal function because it's
used in C extensions:

* rb_thread_fd_select

I added a comment to note that this function, although internal, is used
in C extensions.</pre>
</div>
</content>
</entry>
<entry>
<title>Free the native thread of the main thread on FREE_AT_EXIT</title>
<updated>2025-10-04T22:21:13+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2025-10-03T23:51:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1858233ffaee482a73a91b796f02ebb7ae1306b9'/>
<id>1858233ffaee482a73a91b796f02ebb7ae1306b9</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix blocking operation cancellation. (#13614)</title>
<updated>2025-06-14T03:32:51+00:00</updated>
<author>
<name>Samuel Williams</name>
<email>samuel.williams@oriontransfer.co.nz</email>
</author>
<published>2025-06-14T03:32:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=68625a23d6deeb2e4c498d4bccc36d616608e05f'/>
<id>68625a23d6deeb2e4c498d4bccc36d616608e05f</id>
<content type='text'>
Expose `rb_thread_resolve_unblock_function` internally.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Expose `rb_thread_resolve_unblock_function` internally.</pre>
</div>
</content>
</entry>
<entry>
<title>Add a new_thread flag to rb_interrupt_exec</title>
<updated>2025-06-12T20:13:55+00:00</updated>
<author>
<name>John Hawthorn</name>
<email>john@hawthorn.email</email>
</author>
<published>2025-06-05T20:48:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a34fcf401b5b20c38eb98b42815e17bc2af9bad5'/>
<id>a34fcf401b5b20c38eb98b42815e17bc2af9bad5</id>
<content type='text'>
Previously rb_ractor_interrupt_exec would use an intermediate function
to create a new thread with the actual target function, replacing the
data being passed in with a piece of malloc memory holding the "next"
function and the original data.

Because of this, passing rb_interrupt_exec_flag_value_data to
rb_ractor_interrupt_exec didn't have the intended effect of allowing
data to be passed in and marked.

This commit adds a rb_interrupt_exec_flag_new_thread flag, which
both simplifies the implementation and allows the original data to be
marked.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously rb_ractor_interrupt_exec would use an intermediate function
to create a new thread with the actual target function, replacing the
data being passed in with a piece of malloc memory holding the "next"
function and the original data.

Because of this, passing rb_interrupt_exec_flag_value_data to
rb_ractor_interrupt_exec didn't have the intended effect of allowing
data to be passed in and marked.

This commit adds a rb_interrupt_exec_flag_new_thread flag, which
both simplifies the implementation and allows the original data to be
marked.
</pre>
</div>
</content>
</entry>
<entry>
<title>Allow `IO#close` to interrupt IO operations on fibers using `fiber_interrupt` hook. (#12839)</title>
<updated>2025-05-23T05:55:05+00:00</updated>
<author>
<name>Samuel Williams</name>
<email>samuel.williams@oriontransfer.co.nz</email>
</author>
<published>2025-05-23T05:55:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=73c9d6ccaa2045a011ed991dc29633bd0443971a'/>
<id>73c9d6ccaa2045a011ed991dc29633bd0443971a</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Make `waiting_fd` behaviour per-IO. (#13127)</title>
<updated>2025-05-13T10:02:03+00:00</updated>
<author>
<name>Samuel Williams</name>
<email>samuel.williams@oriontransfer.co.nz</email>
</author>
<published>2025-05-13T10:02:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=425fa0aeb5ced20c03b2d5edb7a409666363ea8f'/>
<id>425fa0aeb5ced20c03b2d5edb7a409666363ea8f</id>
<content type='text'>
- `rb_thread_fd_close` is deprecated and now a no-op.
- IO operations (including close) no longer take a vm-wide lock.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- `rb_thread_fd_close` is deprecated and now a no-op.
- IO operations (including close) no longer take a vm-wide lock.</pre>
</div>
</content>
</entry>
<entry>
<title>Ensure `struct rb_io` is passed through to `thread.c`. (#13134)</title>
<updated>2025-04-19T00:55:16+00:00</updated>
<author>
<name>Samuel Williams</name>
<email>samuel.williams@oriontransfer.co.nz</email>
</author>
<published>2025-04-19T00:55:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=20a1c1dc6be9349521592fc21b17de3eb9f84051'/>
<id>20a1c1dc6be9349521592fc21b17de3eb9f84051</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>introduce `rb_ec_check_ints()`</title>
<updated>2024-11-08T09:02:46+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2024-11-05T17:31:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=97aaf6f760259c639dc3ceb3a80fe82411649569'/>
<id>97aaf6f760259c639dc3ceb3a80fe82411649569</id>
<content type='text'>
to avoid TLS issue with N:M threads.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
to avoid TLS issue with N:M threads.
</pre>
</div>
</content>
</entry>
<entry>
<title>`interrupt_exec`</title>
<updated>2024-11-08T09:02:46+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2024-11-04T18:55:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c8297c3eed571e978dded34dd2036a53d6f28bb3'/>
<id>c8297c3eed571e978dded34dd2036a53d6f28bb3</id>
<content type='text'>
introduce
- rb_threadptr_interrupt_exec
- rb_ractor_interrupt_exec

to intercept the thread/ractor execution.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
introduce
- rb_threadptr_interrupt_exec
- rb_ractor_interrupt_exec

to intercept the thread/ractor execution.
</pre>
</div>
</content>
</entry>
<entry>
<title>Ensure fiber scheduler is woken up when close interrupts read</title>
<updated>2024-09-17T00:11:44+00:00</updated>
<author>
<name>KJ Tsanaktsidis</name>
<email>ktsanaktsidis@zendesk.com</email>
</author>
<published>2024-09-13T07:40:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e08d5239b68ad61a731f4938cf963e37a5e88c25'/>
<id>e08d5239b68ad61a731f4938cf963e37a5e88c25</id>
<content type='text'>
If one thread is reading and another closes that socket, the close
blocks waiting for the read to abort cleanly. This ensures that Ruby is
totally done with the file descriptor _BEFORE_ we tell the OS to close
and potentially re-use it.

When the read is correctly terminated, the close should be unblocked.
That currently works if closing is happening on a thread, but if it's
happening on a fiber with a fiber scheduler, it does NOT work.

This patch ensures that if the close happened in a fiber scheduled
thread, that the scheduler is notified that the fiber is unblocked.

[Bug #20723]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If one thread is reading and another closes that socket, the close
blocks waiting for the read to abort cleanly. This ensures that Ruby is
totally done with the file descriptor _BEFORE_ we tell the OS to close
and potentially re-use it.

When the read is correctly terminated, the close should be unblocked.
That currently works if closing is happening on a thread, but if it's
happening on a fiber with a fiber scheduler, it does NOT work.

This patch ensures that if the close happened in a fiber scheduled
thread, that the scheduler is notified that the fiber is unblocked.

[Bug #20723]
</pre>
</div>
</content>
</entry>
</feed>
