Граф коммитов

26 Коммитов

Автор SHA1 Сообщение Дата
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
Samuel Williams 2553c5f94a Add support for non-blocking `Process.wait`. 2020-12-09 08:55:35 +13:00
Nobuyoshi Nakada d2b7e1e4b2
Protoized old pre-ANSI K&R style definitions 2020-12-05 14:57:31 +09:00
Samuel Williams a08ee8330d Rename to `Fiber#set_scheduler`. 2020-11-07 23:39:50 +13:00
Nobuyoshi Nakada 257007af9a
Added a fallback return 2020-10-01 13:46:13 +09:00
Nobuyoshi Nakada 0e98a9c854
break around function definition [ci skip] 2020-10-01 13:44:29 +09:00
Samuel Williams 13660105e2 Don't call `Scheduler#close` if it doesn't exist. 2020-10-01 16:02:03 +13:00
Samuel Williams 70f08f1eed Make `Thread#join` non-blocking. 2020-09-21 11:48:44 +12:00
Samuel Williams 501fff14c7 When setting current thread scheduler to nil, invoke `#close`. 2020-09-21 09:51:33 +12:00
Benoit Daloze 738a089b3a Rename scheduler.{mutex_lock,mutex_unlock} to {block,unblock}
* Move #kernel_sleep next to #block as it is similar
2020-09-17 14:30:40 +02:00
Benoit Daloze 178c1b0922 Make Mutex per-Fiber instead of per-Thread
* Enables Mutex to be used as synchronization between multiple Fibers
  of the same Thread.
* With a Fiber scheduler we can yield to another Fiber on contended
  Mutex#lock instead of blocking the entire thread.
* This also makes the behavior of Mutex consistent across CRuby, JRuby and TruffleRuby.
* [Feature #16792]
2020-09-14 16:44:09 +12:00
Samuel Williams 701dcbb3ca Add support for hooking `IO#read`. 2020-09-14 16:44:09 +12:00
Samuel Williams d387029f39 Standardised scheduler interface. 2020-09-14 16:44:09 +12:00