summaryrefslogtreecommitdiff
path: root/thread.c
Commit message (Collapse)AuthorAgeFilesLines
* Some codes replace to `RBOOL` macro (#5023)S.H2021-11-091-6/+1
| | | | | | | * Some code replace and using RBOOL macro * Fix indent * Using RBOOL in syserr_eqq function
* [Feature #18290] Remove all usages of rb_gc_force_recyclePeter Zhu2021-11-081-1/+0
| | | | | This commit removes usages of rb_gc_force_recycle since it is a burden to maintain and makes changes to the GC difficult.
* Select including thread impl file at config timeYuta Saito2021-10-301-4/+2
|
* Prefer ANSI-style prototypes over old K&R-style definitionsNobuyoshi Nakada2021-10-271-2/+2
|
* Make Coverage suspendable (#4856)Yusuke Endoh2021-10-251-5/+18
| | | | | | | * Make Coverage suspendable Add `Coverage.suspend`, `Coverage.resume` and some methods. [Feature #18176] [ruby-core:105321]
* suppress warnings by parenthesizing unclear expressionsNobuyoshi Nakada2021-10-241-1/+1
|
* Using NIL_P macro instead of `== Qnil`S.H2021-10-031-1/+1
|
* Remove extraneous conversion to float [Bug #18236]Nobuyoshi Nakada2021-10-031-21/+14
|
* Cast to void pointer to suppress -Wformat-pedantic in RUBY_DEBUG_LOGNobuyoshi Nakada2021-10-031-1/+1
|
* Move some function declaration to internal/io.hS-H-GAMELINKS2021-09-281-5/+0
|
* Refactor and Using RBOOL macroS.H2021-09-151-13/+2
|
* Using RB_BIGNUM_TYPE_P macroS-H-GAMELINKS2021-09-111-1/+1
|
* Fix potential hang when joining threads.Samuel Williams2021-08-031-27/+48
| | | | | | | | | | | 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.
* Using RBOOL macroS.H2021-08-021-24/+10
|
* Revert "Fix potential hang when joining threads."Yusuke Endoh2021-07-281-17/+4
| | | | | | | | | | | 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.
* Predefine recursive key IDNobuyoshi Nakada2021-07-271-2/+1
|
* Fix potential hang when joining threads.Samuel Williams2021-07-271-4/+17
| | | | | | | | | 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.
* Distinguish signal and timeout [Bug #16608]Nobuyoshi Nakada2021-07-251-2/+4
|
* Replace copy coroutine with pthread implementation.Samuel Williams2021-07-011-11/+11
|
* Prefer qualified names under ThreadNobuyoshi Nakada2021-06-291-1/+1
|
* Reduce repeated same codeNobuyoshi Nakada2021-06-241-13/+9
|
* Deprecate and rework old (fd) centric functions.Samuel Williams2021-06-221-33/+0
|
* Adjust styles [ci skip]Nobuyoshi Nakada2021-06-171-5/+10
| | | | | | | | | * --braces-after-func-def-line * --dont-cuddle-else * --procnames-start-lines * --space-after-for * --space-after-if * --space-after-while
* Wake up join list within thread EC context. (#4471)Samuel Williams2021-06-141-79/+77
| | | | | | | | | | | | | | | * 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.
* Suppress clobbered warnings on Travis-CI ppc64le-linuxNobuyoshi Nakada2021-06-031-2/+3
|
* Make `Thread#native_thread_id` not-implemented if unsupportedNobuyoshi Nakada2021-06-011-0/+4
| | | | | Raise `NotImplementedError` on unsupported platforms regardless the argument consistently.
* Add Thread#native_thread_id [Feature #17853]NARUSE, Yui2021-05-261-0/+31
|
* Document how to handle kill/terminate interrupts in Thread.handle_interruptJeremy Evans2021-04-081-0/+2
| | | | | | | | | | | The kill/terminate interrupts are internally handled not as Exception instances, but as integers. So using Exception doesn't handle these interrupts, but Object does. You can use Integer if you only want to handle kill/terminate interrupts, but that's probably more of an implementation detail, while handling Object should work regardless of the implementation. Fixes [Bug #15735]
* Destroy VM-wise locks before freeing [Bug #15852]Nobuyoshi Nakada2021-03-091-7/+0
|
* Make Ractor stdio belonging to the Ractor [Bug #17672]Nobuyoshi Nakada2021-03-071-0/+9
| | | | | Defer making ractor stdio until ractor started. Before ractor started, created objects belong to the caller ractor instead of the created ractor.
* Don't document that Thread#group can return nilJeremy Evans2021-02-101-8/+2
| | | | | | | | Thread's are assigned a group at initialization, and no API exists for them to unassign them from a group without assigning them to another group. Fixes [Bug #17505]
* Expose scheduler as public interface & bug fixes. (#3945)Samuel Williams2021-02-091-8/+8
| | | | | | | | | * 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.
* unblock thread is only for main ractor.Koichi Sasada2021-02-051-2/+2
| | | | | other ractors should not have a unblock thread. This patch fixes 6f727853cee41195b67ee5d793c1ac23fe1a6ae0.
* only main thread can modify vm->ubf_async_safeKoichi Sasada2021-02-031-3/+5
| | | | | | vm->ubf_async_safe is VM global resource and only main thread can manipulate it. [Bug #17482]
* Replace "iff" with "if and only if"Gannon McGibbon2021-01-191-1/+1
| | | | | | | iff means if and only if, but readers without that knowledge might assume this to be a spelling mistake. To me, this seems like exclusionary language that is unnecessary. Simply using "if and only if" instead should suffice.
* introduce rb_ractor_atfork()Koichi Sasada2020-12-241-5/+3
| | | | to reset main ractor at fork().
* Revert "need to clear blocking cnt at fork (child process)"Koichi Sasada2020-12-231-2/+1
| | | | | | This reverts commit 0dd4896175f95c4c2a26d91a97b9fcb9a74cc0c6. It breaks the tests on RUBY_DEBUG=1.
* need to clear blocking cnt at fork (child process)Koichi Sasada2020-12-231-1/+2
|
* fix to use rb_ractor_id()Koichi Sasada2020-12-221-1/+1
| | | | Catch up recent changes on USE_RUBY_DEBUG_LOG=1.
* Introduce negative method cacheKoichi Sasada2020-12-141-0/+2
| | | | pCMC doesn't have negative method cache so this patch implements it.
* fix Thread's interrupt and Ractor#take issueKoichi Sasada2020-12-071-0/+3
| | | | | | | | | Thread's interrupt set Ractor's wakeup_status as interrupted, but the status remains next Ractor communication API. This patch makes to ignore the previous interrupt state. [Bug #17366] Also this patch solves the Thread#kill and Ractor#take issues.
* Protoized old pre-ANSI K&R style definitionsNobuyoshi Nakada2020-12-051-1/+1
|
* Proposed method for dealing with stack locals which have non-local lifetime.Samuel Williams2020-12-051-7/+8
|
* show the error message before Ractor.yieldKoichi Sasada2020-11-251-6/+7
| | | | | | | | | | | Ractor's error will be printed if Thread#report_on_exception is true (default), and error message is used. Without this patch, the exception object is sent by Ractor.yield and it can be shared with another ractor. http://ci.rvm.jp/results/trunk-random3@phosphorus-docker/3269368 To prevent such sharing, show errors befor Ractor.yield().
* fix public interfaceKoichi Sasada2020-11-181-1/+1
| | | | | | | | | | | | | | | | | | To make some kind of Ractor related extensions, some functions should be exposed. * include/ruby/thread_native.h * rb_native_mutex_* * rb_native_cond_* * include/ruby/ractor.h * RB_OBJ_SHAREABLE_P(obj) * rb_ractor_shareable_p(obj) * rb_ractor_std*() * rb_cRactor and rm ractor_pub.h and rename srcdir/ractor.h to srcdir/ractor_core.h (to avoid conflict with include/ruby/ractor.h)
* Threads in a ractor will be killed with the ractorKoichi Sasada2020-11-111-7/+7
| | | | | If a terminating ractor has child threads, then kill all child threads.
* introduce USE_VM_CLOCK for windows.Koichi Sasada2020-11-111-10/+0
| | | | | | | | | | | | | | | | The timer function used on windows system set timer interrupt flag of current main ractor's executing ec and thread can detect the end of time slice. However, to set all ec->interrupt_flag for all running ractors, it is requires to synchronize with other ractors. However, timer thread can not acquire the ractor-wide lock because of some limitation. To solve this issue, this patch introduces USE_VM_CLOCK compile option to introduce rb_vm_t::clock. This clock will be incremented by the timer thread and each thread can check the incrementing by comparison with previous checked clock. At last, on windows platform this patch introduces some overhead, but I think there is no critical performance issue because of this modification.
* Rename to `Fiber#set_scheduler`.Samuel Williams2020-11-071-82/+3
|
* sync vm->waiting_fds correctly.Koichi Sasada2020-10-301-1/+7
| | | | | vm->waiting_fds is global resource so we need to lock it correctly. (forgot to sync one place)
* Add Thread.ignore_deadlock accessorJeremy Evans2020-10-281-1/+51
| | | | | | | | | | Setting this to true disables the deadlock detector. It should only be used in cases where the deadlock could be broken via some external means, such as via a signal. Now that $SAFE is no longer used, replace the safe_level_ VM flag with ignore_deadlock for storing the setting. Fixes [Bug #13768]