Commit graph

505 commits

Author SHA1 Message Date
Nobuyoshi Nakada
2af8b04eca
Fix conversion macro for size_t 2022-03-13 21:10:33 +09:00
Nobuyoshi Nakada
e081f333fe
Fix experimental Fiber::Pool definition
Toplevel `Pool` is too generic, and `struct fiber_pool` does not
seem compatible with `rb_fiber_t`.
2022-03-13 21:09:17 +09:00
Nobuyoshi Nakada
d650b17686
rb_fiber_terminate must not return [Bug #18497]
In a forked process from a fiber, the fiber becomes the only
fiber, `fiber_switch` does nothing as there is no other fibers,
`rb_fiber_terminate` does not terminate the fiber.  In that case,
reaches the end of `fiber_entry` finaly, which is declared as
"COROUTINE" and should never return.
2022-01-19 19:57:16 +09:00
Nobuyoshi Nakada
069cca6f74
Negative RBOOL usage 2022-01-01 17:02:04 +09:00
Samuel Williams
02a9a72f43 Tidy up fiber scheduler interface documentation for address_resolve and timeout_after. 2021-12-21 17:22:55 +13:00
Samuel Williams
711342d935 Update cont.c 2021-12-21 12:32:54 +13:00
zverok
eae5a34be3 Add SchedulerInterface#timeout_after and #address_resolve docs 2021-12-21 12:32:54 +13:00
zverok
224dfb2d6e Document Fiber::SchedulerInterface#io_read and #io_write 2021-12-21 12:32:54 +13:00
Nobuyoshi Nakada
12fbdf4d4e
Fix conflicting declaration on Solaris
SunC
```
"cont.c", line 24: identifier redeclared: madvise
	current : function(pointer to char, unsigned int, int) returning int
	previous: function(pointer to void, unsigned int, int) returning int : "/usr/include/sys/mman.h", line 232
```

GCC
```
cont.c:24:12: error: conflicting types for 'madvise'
   24 | extern int madvise(caddr_t, size_t, int);
      |            ^~~~~~~
In file included from cont.c:16:
/usr/include/sys/mman.h:232:12: note: previous declaration of 'madvise' was here
  232 | extern int madvise(void *, size_t, int);
      |            ^~~~~~~
```
2021-11-30 09:10:58 +09:00
Naohisa Goto
8287d2f23c Workaround for implicit declaration of function 'madvise' on Solaris
On Solaris, madvise(3C) is NOT defined for SUS (XPG4v2) or later,
but MADV_* macros are defined when __EXTENSIONS__ is defined.
This may cause compile error on Solaris 10 with GCC when
"-Werror=implicit-function-declaration" and "-D_XOPEN_SOURCE=600"
are added by configure.
2021-11-30 00:03:04 +09:00
卜部昌平
90f2ab9d62 rb_fiber_raise(): add doxygen
Must not be a bad idea to improve documents.
2021-09-30 20:55:23 +13:00
Samuel Williams
88ba5fe547 Expose rb_fiber_raise and tidy up the internal implementation. 2021-09-20 18:30:51 +12:00
Nobuyoshi Nakada
9c5ad5d42d
Suppress format-pedantic warnings 2021-09-02 08:47:47 +09:00
Nobuyoshi Nakada
28d03ee776 Remove root_jmpbuf in rb_thread_struct
It has not been used since 1b82c877df.
2021-08-10 19:08:38 +09:00
S-H-GAMELINKS
ac7986f46a Remove unneeded rb_fiber_transfer_kw declaration 2021-08-07 17:18:20 +12:00
S.H
378e8cdad6
Using RBOOL macro 2021-08-02 12:06:44 +09:00
Nobuyoshi Nakada
ab37e6ee7e
Adjust styles [ci skip]
* --procnames-start-lines
2021-07-18 19:55:07 +09:00
Kazuki Yamaguchi
4885c44bca cont.c: fix formatting of RDoc for Fiber class 2021-07-17 13:37:41 +09:00
Samuel Williams
42130a64f0
Replace copy coroutine with pthread implementation. 2021-07-01 11:23:03 +12:00
nagachika
8366506de1 cont.c: Replace "iff" with "if and only if" 2021-06-12 20:15:08 +09:00
Nobuyoshi Nakada
93be7a4c6b
Suppress clobbered warnings on Travis-CI ppc64le-linux 2021-06-03 20:07:26 +09:00
Samuel Williams
dc25412042 Expose rb_fiber_transfer and rb_fiber_transfer_kw. 2021-06-03 20:47:31 +12:00
Ryuta Kamizono
33f2ff3bab Fix some typos by spell checker 2021-04-26 10:07:41 +09:00
Samuel Williams
92449e0e99 Fix handling of timeout accessing scheduler outside of non-blocking context. 2021-03-30 18:38:42 +13:00
David CARLIER
875c85a8bd fiber context update for Mac OS.
it is more about memory accounting sake. At allocation time,
 we make clear we re possibly reusing regions marked as reusable.
Noted also calls might not necessarily succeed at first so we do
 only when necessary.
2021-03-29 09:32:40 +13:00
David Carlier
5e16c3a12a solaris/illumos build fix. 2021-03-22 22:51:15 +09:00
Kazuhiro NISHIYAMA
ad0fa53203
[DOC] some methods of Fiber do not need to require anymore [Feature #17407] 2021-03-22 18:59:25 +09:00
Nobuyoshi Nakada
d91ade3e1e
Renamed functions for Fiber singleton methods 2021-03-12 18:15:56 +09:00
Nobuyoshi Nakada
90c12defb3
Constified variables for getenv 2021-03-12 17:13:53 +09:00
Nobuyoshi Nakada
9d8c66fd6a
rb_fiber_terminate never returns 2021-02-24 04:09:57 +09:00
nicholas a. evans
3ee4fa9491
Send :fiber_switch event for almost every fiber_switch (#4207)
With this patch, TracePoint receives a `:fiber_switch` event for
_almost_ every fiber switch.  Previously, it would not be sent when an
exception was going to be raised. Now the event should only be blockable
by an interrupt (including `Thread#raise`) or a fatal error.

Additionally, interrupts will now be checked on the return fiber
_before_ re-raising the terminating unhandled exception.  And a fiber
that terminates with an unhandled exception no longer creates a pending
interrupt on its thread.  The exception will be raised in the return
fiber the same way as `Fiber#raise`: using `cont.value` with `cont.argc
== -1`

I moved `rb_exc_raise` from `fiber_store` to the end of `fiber_switch`
after _all_ of the other cleanup code: `fiber_stack_release`,
`th->blocking` increment, `RUBY_VM_CHECK_INTS`, and `EXEC_EVENT_HOOK`.
It seems to me that skipping those other cleanup steps may have also
resulted in other bugs.
2021-02-22 10:33:11 +13: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
Nobuyoshi Nakada
521ad9a13a Moved Fiber methods into core [Feature #17407] 2021-01-13 23:20:02 +09:00
Marcus Stollsteimer
3108ad7bf3 [DOC] Fix grammar: "is same as" -> "is the same as" 2021-01-05 15:13:53 +01:00
Nobuyoshi Nakada
09aca50fc4
Adjusted styles [ci skip] 2020-12-28 19:52:14 +09:00
Marc-Andre Lafortune
cf1f9bdc8d Language tweaks to Fiber [doc] 2020-12-27 16:09:06 -05:00
Kazuhiro NISHIYAMA
2c752ff930
Fix a typo [ci skip] 2020-12-24 23:13:36 +09:00
zverok
1415653c84 Redocument non-blocking Fibers and scheduler
* Document Fiber's method related to scheduling;
* Extend Fiber's class docs with concepts of non-blocking
  fibers;
* Introduce "imaginary" (documentation-only) class
  Fiber::SchedulerInterface to properly document how
  scheduler's methods should look.
2020-12-24 03:03:51 -05:00
zverok
24ae0e8ed7 Review comments 2020-12-24 14:37:09 +09:00
zverok
5696c69354 Redocument Fiber#transfer 2020-12-24 14:37:09 +09:00
Delton Ding
c6d7e02b90 Enable Fiber.current and Fiber#alive? call inside ractor 2020-12-23 03:27:14 +09:00
Marc-Andre Lafortune
d0050edb84 Update Fiber#backtrace doc [See bug #17408] 2020-12-21 21:07:13 -05:00
zverok
843fd1e8cf Document Fiber#backtrace and #backtrace_locations 2020-12-21 19:22:38 -05:00
nicholas a. evans
31e8de2920 Let Fiber#raise work with transferring fibers
This automatically choosess whether to use transfer on a transferring
fiber or resume on a yielding fiber.  If the fiber is resuming, it
raises a FiberError.
2020-12-12 10:18:19 +13:00
Takashi Kokubun
01f38693aa
Remove obsoleted internal/mjit.h inclusion
🙇
2020-11-22 20:28:34 -08:00
Takashi Kokubun
e0156bd396
Make sure all threads are scanned on unload_units
This has been a TODO since 79df14c04b. While adcf0316d1 covered the
root_fiber of the initial thread, it didn't cover root_fibers of other
threads. Now it's hooked properly in rb_threadptr_root_fiber_setup.

With regards to "XXX: Is this mjit_cont `mjit_cont_free`d?", when
rb_threadptr_root_fiber_release is called, although I'm not sure when
th->root_fiber is truthy, fiber_free seems to call cont_free and
mjit_cont_free. So mjit_conts of root_fibers seem to be freed properly.
2020-11-21 19:36:55 -08:00
Koichi Sasada
5e3259ea74 fix public interface
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)
2020-11-18 03:52:41 +09:00
Nobuyoshi Nakada
0d52dce3a3
strip trailing spaces and adjusted indents [ci skip] 2020-11-12 19:27:20 +09:00
Samuel Williams
a08ee8330d Rename to Fiber#set_scheduler. 2020-11-07 23:39:50 +13:00
Kazuhiro NISHIYAMA
0714cb760c
Remove duplicated line [ci skip]
ref bf3b2a4374
2020-10-14 15:16:36 +09:00