Victor Shepelev
01d1cbbbec
[DOC] Enhance Fiber::Scheduler docs ( #15708 )
2025-12-24 00:53:08 +00:00
Luke Gruber
3add3db797
Fewer calls to GET_EC() and GET_THREAD() ( #15506 )
...
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.
2025-12-12 14:47:43 -05:00
Samuel Williams
42f5654b69
Yield to scheduler if interrupts are pending. ( #14700 )
2025-12-06 21:44:14 +13:00
Samuel Williams
180020e1e5
Fix io_pwrite fiber scheduler hook. ( #15428 )
...
Fix io_pwrite fiber scheduler hook.
2025-12-06 20:35:08 +13:00
Samuel Williams
e6879401fe
Use ec->interrupt_mask to prevent interrupts. ( #14588 )
...
Disallow pending interrupts to be checked during `FiberScheduler#unblock`.
Ractors can send signals at any time, so the previous debug assertion
can fail if a Ractor sends a signal.
Co-authored-by: Luke Gruber <luke.gruber@shopify.com>
2025-09-18 14:24:29 +12:00
Nobuyoshi Nakada
6179cc0118
[DOC] Fill undocumented documents
2025-08-04 02:23:43 +09:00
Samuel Williams
68625a23d6
Fix blocking operation cancellation. ( #13614 )
...
Expose `rb_thread_resolve_unblock_function` internally.
2025-06-14 12:32:51 +09:00
Samuel Williams
cdeedd5bc1
Fix handling of cancelled blocking operations. ( #13570 )
2025-06-10 07:30:43 +00:00
Samuel Williams
dde9fca63b
Be more specific with RUBY_VM_INTERRUPTED in debug assertions.
2025-06-06 20:29:04 +09:00
Samuel Williams
5ac435dc34
Log ec->interrupt_flag if non-zero.
2025-06-06 18:15:41 +09:00
Samuel Williams
ead14b19aa
Fix blocking_operation_wait use-after-free bug.
2025-06-06 13:13:16 +09:00
Samuel Williams
81a23c5793
rb_io_blocking_operation_exit should not execute with pending interrupts.
2025-06-06 13:13:16 +09:00
Samuel Williams
9a29252830
Fix compatibility with fiber schedulers that don't implement #fiber_interrupt. ( #13492 )
2025-06-02 18:50:23 +09:00
Samuel Williams
73c9d6ccaa
Allow IO#close to interrupt IO operations on fibers using fiber_interrupt hook. ( #12839 )
2025-05-23 14:55:05 +09:00
Samuel Williams
d32fa5283f
Prefer 0.000001 over 0.000001f for timeout calculations. ( #12803 )
2025-02-25 16:37:21 +13:00
Samuel Williams
04ec077946
Preserve errno in rb_fiber_scheduler_unblock. ( #12576 )
...
[Bug #21038 ]
Co-authored-by: Julian Scheid <julians37@gmail.com>
2025-01-15 14:59:46 +13:00
Alan Wu
5ed1dac21e
[DOC] Have RDoc pick up Fiber::Scheduler#blocking_operation_wait
...
... and list it.
2024-12-13 14:21:46 -05:00
Samuel Williams
03ff7db5fe
Update scheduler.c to use RUBY_ASSERT. ( #12129 )
2024-11-20 23:00:55 +00:00
Samuel Williams
9c268302bf
Introduce Fiber::Scheduler#blocking_operation_wait. ( #12016 )
...
Redirect `rb_nogvl` blocking operations to the fiber scheduler if possible
to prevent stalling the event loop.
[Feature #20876 ]
2024-11-20 19:40:17 +13:00
Samuel Williams
3b9896acfc
Revert "Introduce Fiber Scheduler blocking_region hook. ( #11963 )" ( #12013 )
...
This reverts some of commit 87fb44dff6409a19d12052cf0fc07ba80a4c45ac.
We will rename and propose a slightly different interface.
2024-11-06 22:19:40 +13:00
Samuel Williams
87fb44dff6
Introduce Fiber Scheduler blocking_region hook. ( #11963 )
2024-10-31 17:26:37 +13:00
Samuel Williams
04729fe68d
Fix exception handling in rb_fiber_scheduler_set. ( #10042 )
2024-02-22 00:33:18 +13:00
kudojp
0e49f8173a
[DOC] Fix method docs of scheduler#io_read and scheduler#io_write
...
Each of Fiber::Scheduler#io_read and io_write takes the "offset" as the fourth argument, which is not doucmented.
2023-09-10 19:39:28 +09:00
Samuel Williams
648870b5c5
Support IO#pread / IO#pwrite using fiber scheduler. ( #7594 )
...
* Skip test if non-blocking file IO is not supported.
2023-03-31 00:48:55 +13:00
Samuel Williams
466aa8010f
Fix incorrect usage of rb_fiber_scheduler_io_(p)(read|write). ( #7593 )
2023-03-25 18:36:27 +13:00
Victor Shepelev
c3c116f6a6
[DOC] Document new methods of IO::Buffer and Fiber::Scheduler ( #7016 )
...
Co-authored-by: Samuel Williams <samuel.williams@oriontransfer.co.nz>
2022-12-24 11:48:58 +13:00
S-H-GAMELINKS
1f4f6c9832
Using UNDEF_P macro
2022-11-16 18:58:33 +09:00
Samuel Williams
7fcad1fa03
Update Fiber::Scheduler documentation. ( #6562 )
2022-10-15 21:43:45 +13:00
Samuel Williams
8a420670a2
Introduce Fiber::Scheduler#io_select hook for non-blocking IO.select. ( #6559 )
2022-10-15 19:59:04 +13:00
Samuel Williams
ced1d17280
Improvements to IO::Buffer implementation and documentation. ( #6525 )
2022-10-12 12:59:05 +13:00
Samuel Williams
e4f91bbdba
Add IO#timeout attribute and use it for blocking IO operations. ( #5653 )
2022-10-07 21:48:38 +13:00
Nobuyoshi Nakada
e2ccb316b4
[Bug #5317 ] Use rb_off_t instead of off_t
...
Get rid of the conflict with system-provided small `off_t`.
2022-09-08 23:01:07 +09:00
Samuel Williams
bed920f073
Add fiber scheduler hooks for pread/pwrite, and add support to IO::Buffer.
2021-12-23 12:20:09 +13:00
Samuel Williams
617687df09
Rename IMMUTABLE to READONLY.
2021-12-21 12:25:42 +13:00
Samuel Williams
56811617ab
Improve IO::Buffer resize and introduce ownership transfer.
2021-12-20 00:17:17 +13:00
Samuel Williams
4b89034218
IO::Buffer for scheduler interface.
2021-11-10 19:21:05 +13:00
Samuel Williams
b61064b821
Add gvl and fiber assertions to scheduler interface to catch invalid usage.
2021-09-20 23:16:45 +12:00
Samuel Williams
cb8434563d
Add alternative optional hook for scheduler_close to allow public usage of close.
2021-09-20 22:07:58 +12:00
Nobuyoshi Nakada
e4f891ce8d
Adjust styles [ci skip]
...
* --braces-after-func-def-line
* --dont-cuddle-else
* --procnames-start-lines
* --space-after-for
* --space-after-if
* --space-after-while
2021-06-17 10:13:40 +09:00
Nobuyoshi Nakada
b513fc2fe7
Fixed method names in exception messages
...
These methods are not !-suffixed, and the messages were very
confusing.
2021-06-14 21:16:43 +09:00
Samuel Williams
050a895439
Wake up join list within thread EC context. ( #4471 )
...
* Wake up join list within thread EC context.
* Consume items from join list so that they are not re-executed.
If `rb_fiber_scheduler_unblock` raises an exception, it can result in a
segfault if `rb_threadptr_join_list_wakeup` is not within a valid EC. This
change moves `rb_threadptr_join_list_wakeup` into the thread's top level EC
which initially caused an infinite loop because on exception will retry. We
explicitly remove items from the thread's join list to avoid this situation.
* Verify the required scheduler interface.
* Test several scheduler hooks methods with broken `unblock` implementation.
2021-06-14 17:56:53 +12:00
Samuel Williams
2792acc8f2
Add scheduler hook Addrinfo.getaddrinfo. ( #4375 )
...
Co-authored-by: Bruno Sutic <code@brunosutic.com>
2021-06-14 16:21:08 +12:00
Samuel Williams
3d32c21758
Disable public interface for now.
2021-03-30 18:38:42 +13:00
Samuel Williams
511acba4ae
Update method name and add documentation.
2021-03-30 18:38:42 +13:00
Samuel Williams
09c865d541
Fix native implementation.
...
# Conflicts:
# scheduler.c
2021-03-30 18:38:42 +13:00
Nobuyoshi Nakada
67f60ebb64
Fixed a compilation error
2021-03-30 18:38:42 +13:00
Samuel Williams
c05dd7dc85
Prefer rb_check_funcall.
2021-03-30 18:38:42 +13:00
Samuel Williams
4c53dc970b
Add hook for Timeout.timeout.
2021-03-30 18:38:42 +13:00
Nobuyoshi Nakada
8776606b1d
strip trailing spaces [ci skip]
2021-02-09 16:59:15 +09:00
Samuel Williams
5f69a7f604
Expose scheduler as public interface & bug fixes. ( #3945 )
...
* Rename `rb_scheduler` to `rb_fiber_scheduler`.
* Use public interface if available.
* Use `rb_check_funcall` where possible.
* Don't use `unblock` unless the fiber was non-blocking.
2021-02-09 19:39:56 +13:00