summaryrefslogtreecommitdiff
path: root/test/fiber
AgeCommit message (Collapse)Author
2021-08-26Fix example fiber scheduler reg. writable eventsLars Kanis
There were two issues: 1. When an IO object is waiting for writablility only (as in test_tcp_accept) the selected hash is empty. Therefore selected[fiber] returns nil but needs to default to 0 in order to be or'ed with IO::WRITABLE. 2. When an IO object is waiting for read- or writability (as in test_tcp_connect), but only one of these two events arrive, the Fiber and IO object need to be removed from the other `@readable` or `@writable` list. Notes: Merged: https://github.com/ruby/ruby/pull/4777
2021-08-03Fix potential hang when joining threads.Samuel Williams
If the thread termination invokes user code after `th->status` becomes `THREAD_KILLED`, and the user unblock function causes that `th->status` to become something else (e.g. `THREAD_RUNNING`), threads waiting in `thread_join_sleep` will hang forever. We move the unblock function call to before the thread status is updated, and allow threads to join as soon as `th->value` becomes defined. This reverts commit 6505c77501f1924571b2fe620c5c7b31ede0cd22. Notes: Merged: https://github.com/ruby/ruby/pull/4689
2021-07-28Revert "Fix potential hang when joining threads."Yusuke Endoh
This reverts commit 13f8521c630a15c87398dee0763e95f59c032a94. http://rubyci.s3.amazonaws.com/solaris11-gcc/ruby-master/log/20210727T230009Z.fail.html.gz http://rubyci.s3.amazonaws.com/solaris11-sunc/ruby-master/log/20210728T000009Z.fail.html.gz This revert is to confirm whether the commit is the cause. If the failures consistently occur after this revert, I'll reintroduce the commit.
2021-07-27Fix potential hang when joining threads.Samuel Williams
If the thread termination invokes user code after `th->status` becomes `THREAD_KILLED`, and the user unblock function causes that `th->status` to become something else (e.g. `THREAD_RUNNING`), threads waiting in `thread_join_sleep` will hang forever. We move the unblock function call to before the thread status is updated, and allow threads to join as soon as `th->value` becomes defined. Notes: Merged: https://github.com/ruby/ruby/pull/4660
2021-06-29Prefer qualified names under ThreadNobuyoshi Nakada
2021-06-15Suppress exception report in inner threadNobuyoshi Nakada
2021-06-15Close leaked file descriptorsNobuyoshi Nakada
2021-06-14Fix fiber scheduler address resolve solaris testsBruno Sutic
Notes: Merged: https://github.com/ruby/ruby/pull/4571
2021-06-14Wake up join list within thread EC context. (#4471)Samuel Williams
* 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. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2021-06-14Add scheduler hook `Addrinfo.getaddrinfo`. (#4375)Samuel Williams
Co-authored-by: Bruno Sutic <code@brunosutic.com> Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2021-03-30Test incorrect behaviour of `rb_io_wait_readable/writable`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/4338
2021-03-30Fix handling of timeout accessing scheduler outside of non-blocking context.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/4173
2021-03-30Improve timeout tests.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/4173
2021-03-30Update method name and add documentation.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/4173
2021-03-30Add hook for `Timeout.timeout`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/4173
2021-02-09Expose scheduler as public interface & bug fixes. (#3945)Samuel Williams
* 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. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2020-12-23Add verbose nil in testingDelton Ding
Notes: Merged: https://github.com/ruby/ruby/pull/3971
2020-12-23Enable `Fiber.current` and `Fiber#alive?` call inside ractorDelton Ding
Notes: Merged: https://github.com/ruby/ruby/pull/3971
2020-12-09Add support for non-blocking `Process.wait`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3853
2020-11-08Fix TestFiberMutex#test_condition_variable assertionBenoit Daloze
* Now that it works correctly.
2020-11-08Urgent notification pipe has same lifetime as scheduler.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3743
2020-11-08Defer `kernel_sleep` to `block` to avoid exiting the event loop when ↵Samuel Williams
duration is nil. Notes: Merged: https://github.com/ruby/ruby/pull/3743
2020-11-07Rename to `Fiber#set_scheduler`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3742
2020-10-01Refined assertions for better failure messagesNobuyoshi Nakada
2020-10-01strip trailing spaces [ci skip]Nobuyoshi Nakada
2020-10-01Remove `Thread.scheduler` from public interface.Samuel Williams
It's implementation is equivalent to: Thread.current.scheduler unless Thread.current.blocking? Notes: Merged: https://github.com/ruby/ruby/pull/3610
2020-10-01Raise an exception if the scheduler was already closed.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3612
2020-10-01Don't call `Scheduler#close` if it doesn't exist.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3612
2020-09-30Fix order of operations during `rb_ec_finalize`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3605
2020-09-28Remove unnecessary executable bit [ci skip]Kazuhiro NISHIYAMA
2020-09-24test/fiber/scheduler.rb: Prevent "instance variable @urgent not initialized"Yusuke Endoh
2020-09-23strip trailing spaces [ci skip]Nobuyoshi Nakada
2020-09-21Simplify the implementation of Scheduler#blockBenoit Daloze
* This shows block() with a timeout is similar to #kernel_sleep and also does not need to change `@blocking`.
2020-09-21Make `Thread#join` non-blocking.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3558
2020-09-21When setting current thread scheduler to nil, invoke `#close`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3557
2020-09-20Remove from waiter in Mutex#lock with ensure when calling rb_scheduler_block()Benoit Daloze
* 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-17Add missing goto found;Benoit Daloze
* 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-17Fix Mutex#unlock with a scheduler and thread contentionBenoit Daloze
* It would hit "[BUG] unexpected THREAD_STOPPED" before.
2020-09-17Document the various scheduler hooksBenoit Daloze
2020-09-17Call scheduler.block instead of scheduler.kernel_sleep for blocking ↵Benoit Daloze
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-17Rename scheduler.{mutex_lock,mutex_unlock} to {block,unblock}Benoit Daloze
* Move #kernel_sleep next to #block as it is similar
2020-09-17Use a similar pattern for waiting and readyBenoit Daloze
2020-09-16Add a note at the top of the test schedulerBenoit Daloze
2020-09-14Add support for Queue & SizedQueue.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3434
2020-09-14Add support for ConditionVariable.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3434
2020-09-14Improve handling of urgent notification pipe.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3434
2020-09-14Make Mutex per-Fiber instead of per-ThreadBenoit Daloze
* 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] Notes: Merged: https://github.com/ruby/ruby/pull/3434
2020-09-14Rename `Fiber{}` to `Fiber.schedule{}`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3434
2020-09-14Standardised scheduler interface.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3434
2020-09-14Simplify bitmasks for IO events.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3434