diff options
author | Koichi Sasada <ko1@atdot.net> | 2020-10-20 10:46:43 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2020-10-20 15:38:54 +0900 |
commit | 99310e3eb56fbc85bb45119285812eb959448d0c (patch) | |
tree | ae11ca7bf99ff3b1d60d297c63d64e0540fe51c0 /re.c | |
parent | 9ced5fae6df9e70506ddad822e15745884e365fd (diff) |
Some global variables can be accessed from ractors
Some global variables should be used from non-main Ractors.
[Bug #17268]
```ruby
# ractor-local (derived from created ractor): debug
'$DEBUG' => $DEBUG,
'$-d' => $-d,
# ractor-local (derived from created ractor): verbose
'$VERBOSE' => $VERBOSE,
'$-w' => $-w,
'$-W' => $-W,
'$-v' => $-v,
# process-local (readonly): other commandline parameters
'$-p' => $-p,
'$-l' => $-l,
'$-a' => $-a,
# process-local (readonly): getpid
'$$' => $$,
# thread local: process result
'$?' => $?,
# scope local: match
'$~' => $~.inspect,
'$&' => $&,
'$`' => $`,
'$\'' => $',
'$+' => $+,
'$1' => $1,
# scope local: last line
'$_' => $_,
# scope local: last backtrace
'$@' => $@,
'$!' => $!,
# ractor local: stdin, out, err
'$stdin' => $stdin.inspect,
'$stdout' => $stdout.inspect,
'$stderr' => $stderr.inspect,
```
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3670
Diffstat (limited to 're.c')
-rw-r--r-- | re.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -19,6 +19,7 @@ #include "internal/imemo.h" #include "internal/re.h" #include "internal/string.h" +#include "internal/variable.h" #include "regint.h" #include "ruby/encoding.h" #include "ruby/re.h" @@ -4052,6 +4053,12 @@ Init_Regexp(void) rb_define_virtual_variable("$'", postmatch_getter, 0); rb_define_virtual_variable("$+", last_paren_match_getter, 0); + rb_gvar_ractor_local("$~"); + rb_gvar_ractor_local("$&"); + rb_gvar_ractor_local("$`"); + rb_gvar_ractor_local("$'"); + rb_gvar_ractor_local("$+"); + rb_define_virtual_variable("$=", ignorecase_getter, ignorecase_setter); rb_define_virtual_variable("$KCODE", kcode_getter, kcode_setter); rb_define_virtual_variable("$-K", kcode_getter, kcode_setter); |