1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
Commit graph

44 commits

Author SHA1 Message Date
Benoit Daloze
b8eb08e096 Fix TestFiberMutex#test_condition_variable assertion
* Now that it works correctly.
2020-11-08 16:49:33 +01:00
Samuel Williams
bed4848661 Urgent notification pipe has same lifetime as scheduler. 2020-11-08 20:40:52 +13:00
Samuel Williams
57b83dad4c Defer kernel_sleep to block to avoid exiting the event loop when duration is nil. 2020-11-08 20:40:52 +13:00
Samuel Williams
a08ee8330d Rename to Fiber#set_scheduler. 2020-11-07 23:39:50 +13:00
Nobuyoshi Nakada
1d3024da26
Refined assertions for better failure messages 2020-10-01 13:48:15 +09:00
Nobuyoshi Nakada
eef12cdc06
strip trailing spaces [ci skip] 2020-10-01 13:47:57 +09:00
Samuel Williams
dd2e95fb26 Remove Thread.scheduler from public interface.
It's implementation is equivalent to:

Thread.current.scheduler unless Thread.current.blocking?
2020-10-01 16:56:05 +13:00
Samuel Williams
7f29020590 Raise an exception if the scheduler was already closed. 2020-10-01 16:02:03 +13:00
Samuel Williams
13660105e2 Don't call Scheduler#close if it doesn't exist. 2020-10-01 16:02:03 +13:00
Samuel Williams
388281c5c9 Fix order of operations during rb_ec_finalize. 2020-09-30 16:34:38 +13:00
Kazuhiro NISHIYAMA
ac414139ec
Remove unnecessary executable bit [ci skip] 2020-09-28 23:07:43 +09:00
Yusuke Endoh
416bb11a5e test/fiber/scheduler.rb: Prevent "instance variable @urgent not initialized" 2020-09-24 19:29:54 +09:00
Nobuyoshi Nakada
b57c54679b
strip trailing spaces [ci skip] 2020-09-23 17:47:30 +09:00
Benoit Daloze
2b73e6ba71 Simplify the implementation of Scheduler#block
* This shows block() with a timeout is similar to #kernel_sleep and also
  does not need to change `@blocking`.
2020-09-21 16:04:20 +02: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
6987c8997e Remove from waiter in Mutex#lock with ensure when calling rb_scheduler_block()
* Previously this could lead to an invalid waiter entry and then trying
  to wake up that waiter would result in various issues in rb_mutex_unlock_th().
2020-09-20 13:35:39 +02:00
Benoit Daloze
d01954632d Add missing goto found;
* To still remove the lock from the Thread's list of acquired locks.
* Also to not wake up other waiters and preserve blocking behavior.
2020-09-17 17:26:52 +02:00
Benoit Daloze
264889ec3d Fix Mutex#unlock with a scheduler and thread contention
* It would hit "[BUG] unexpected THREAD_STOPPED" before.
2020-09-17 15:15:43 +02:00
Benoit Daloze
deffb63021 Document the various scheduler hooks 2020-09-17 14:59:38 +02:00
Benoit Daloze
9472d16061 Call scheduler.block instead of scheduler.kernel_sleep for blocking Queue/SizedQueue operations
* scheduler.unblock was already already called before but with no corresponding scheduler.block
* add test that Queue#pop makes the scheduler wait until it gets an element.
2020-09-17 14:59:38 +02: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
c3acfcc78d Use a similar pattern for waiting and ready 2020-09-17 14:14:49 +02:00
Benoit Daloze
10290da54d Add a note at the top of the test scheduler 2020-09-16 11:37:06 +02:00
Samuel Williams
8eea66a0ca Add support for Queue & SizedQueue. 2020-09-14 16:44:09 +12:00
Samuel Williams
0f613cc5f1 Add support for ConditionVariable. 2020-09-14 16:44:09 +12:00
Samuel Williams
1a0cfe2839 Improve handling of urgent notification pipe. 2020-09-14 16:44:09 +12: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 ]
2020-09-14 16:44:09 +12:00
Samuel Williams
132453fa52 Rename Fiber{} to Fiber.schedule{}. 2020-09-14 16:44:09 +12:00
Samuel Williams
d387029f39 Standardised scheduler interface. 2020-09-14 16:44:09 +12:00
Samuel Williams
905e9c8093 Simplify bitmasks for IO events. 2020-09-14 16:44:09 +12:00
Yusuke Endoh
701217572f test/fiber/test_backtrace.rb: prevent a warning
```
/home/chkbuild/chkbuild/tmp/build/20200818T033004Z/ruby/test/fiber/test_backtrace.rb:9:
warning: ambiguous first argument; put parentheses or a space even after
`/' operator
/home/chkbuild/chkbuild/tmp/build/20200818T033004Z/ruby/test/fiber/test_backtrace.rb:15:
warning: ambiguous first argument; put parentheses or a space even after
`/' operator
```
2020-08-18 14:36:39 +09:00
Samuel Williams
0a218a97ad Expose ec -> backtrace (internal) and use it to implement fiber backtrace.
See <https://bugs.ruby-lang.org/issues/16815> for more details.
2020-08-18 00:56:35 +12:00
Yusuke Endoh
098e8c2873 Suppress "assigned but unused variable" warnings 2020-07-23 23:44:25 +09:00
Nobuyoshi Nakada
d2bf6133f6
Remove trailing spaces [ci skip] 2020-07-20 13:34:16 +09:00
Samuel Williams
9f6a3d0306 Add multi-threaded I/O test. 2020-07-20 13:20:58 +12:00
Samuel Williams
e6e9cef06e Improve consistency of tests. 2020-07-20 13:20:58 +12:00
Samuel Williams
238464863a Remove fiber HTTP test.
The HTTP test hits a remote website which isn't always available and is
not self-contained. Ideally we will rewrite this test with an internal
web server.
2020-07-16 13:43:56 +12:00
Nobuyoshi Nakada
79d06483a8
Close sockets if blocking to fix leaked fds 2020-07-15 16:36:57 +09:00
Nobuyoshi Nakada
101d56ddca
Improved assertions 2020-06-09 21:42:25 +09:00
nicholas a. evans
b6bae0ec44 Return seconds slept after Thread.scheduler wait_sleep
Kernel#sleep should still return seconds slept, even when using a
Thread.scheduler. The return value of Scheduler#wait_sleep can be
ignored.
2020-06-09 18:57:17 +09:00
Hiroshi SHIBATA
b2976a4fca
Fixup d48c92aa04 2020-05-23 17:24:29 +09:00
Hiroshi SHIBATA
d48c92aa04
Rename TestScheduler* to TestFiber for convention of the test directory 2020-05-23 16:44:57 +09:00
Samuel Williams
6fa8455ebb Move test/scheduler -> test/fiber [Bug ][ruby-core:98366]. 2020-05-15 13:26:23 +12:00