Граф коммитов

1742 Коммитов

Автор SHA1 Сообщение Дата
Kenichi Kamiya 52fb0a2932 [Doc] Drop signature around removed IO#codepoints
Follow 43b95bafd5
2021-04-05 11:47:42 +09:00
Samuel Williams a9c5c2d614 Check errno before invoking scheduler in `rb_io_wait_readable/writable`.
See <https://bugs.ruby-lang.org/issues/17527> for more details.
2021-03-30 23:16:59 +13:00
S.H 71ba09632b
Remove unneeded declarations 2021-03-20 21:00:29 +09: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 bf627e518d
Forward keyword arguments to ARGF from global functions 2021-02-08 11:33:53 +09:00
Yusuke Endoh 33fb87cc9c io.c: popen is not available on emscripten 2021-01-23 13:24:06 +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 ae1cc3fd4e
Made an internal callback function static 2020-12-20 14:29:31 +09:00
Jeremy Evans 05313c914b Use category: :deprecated in warnings that are related to deprecation
Also document that both :deprecated and :experimental are supported
:category option values.

The locations where warnings were marked as deprecation warnings
was previously reviewed by shyouhei.

Comment a couple locations where deprecation warnings should probably
be used but are not currently used because deprecation warning
enablement has not occurred at the time they are called
(RUBY_FREE_MIN, RUBY_HEAP_MIN_SLOTS, -K).

Add assert_deprecated_warn to test assertions.  Use this to simplify
some tests, and fix failing tests after marking some warnings with
deprecated category.
2020-12-18 09:54:11 -08:00
Nobuyoshi Nakada b419f90a8b
Tweaked `Process::Status.wait`
* revert `rb_last_status_set`
* renamed the new function as `rb_process_status_new`
* `rb_process_status_new` always freezes the return value
* marked `Process::Status.wait` as EXPERIMENTAL, as it has not
  been discussed totally yet.
2020-12-09 11:51:57 +09:00
Samuel Williams 2553c5f94a Add support for non-blocking `Process.wait`. 2020-12-09 08:55:35 +13:00
卜部昌平 43b95bafd5
delete deprecated IO-like methods
This commit deletes
{IO,ARGF,StringIO,Zib::GZipReader}#{bytes,chars,lines,codepoints}, which
have been deprecated since c47c095b97.

Note that String also has those methods.  They are neither depreacted
nor deleted because they are not aliases of counterpart each_something.
2020-12-03 12:47:51 +09: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
Samuel Williams a08ee8330d Rename to `Fiber#set_scheduler`. 2020-11-07 23:39:50 +13:00
Jeremy Evans 58fd54f914 Fix error in update-deps due to tab/space difference 2020-10-28 15:29:05 -07:00
Stefan Stüben 8c2e5bbf58 Don't redefine #rb_intern over and over again 2020-10-21 12:45:18 +09:00
Koichi Sasada 99310e3eb5 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,
```
2020-10-20 15:38:54 +09:00
Nobuyoshi Nakada fddffa4c7a
Respect the original styles [ci skip] 2020-10-11 11:57:32 +09:00
Samuel Williams f75009c122 Prefer to use `prep_io` for temporary IO instances. 2020-09-17 00:31:04 +12:00
Samuel Williams 026ba68c10 Fix handling of FMODE_PREP. 2020-09-15 22:53:08 +12:00
Samuel Williams a9b2a96c5c Fix incorrect initialization of `rb_io_t::self`. 2020-09-15 22:53:08 +12:00
Samuel Williams 9e0a48c7a3 Prefer `rb_thread_current_scheduler`. 2020-09-14 16:44:09 +12:00
Samuel Williams 701dcbb3ca Add support for hooking `IO#read`. 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
Masaki Matsushita 012785ef35 Check copy_file_range(2) is actually supported.
see also: https://gitlab.com/gitlab-org/gitlab/-/issues/218999#note_363225872
2020-09-12 16:07:35 +09:00
Nobuyoshi Nakada f943566d1c
break around function definition [ci skip] 2020-09-05 00:34:58 +09:00
Koichi Sasada 79df14c04b Introduce Ractor mechanism for parallel execution
This commit introduces Ractor mechanism to run Ruby program in
parallel. See doc/ractor.md for more details about Ractor.
See ticket [Feature #17100] to see the implementation details
and discussions.

[Feature #17100]

This commit does not complete the implementation. You can find
many bugs on using Ractor. Also the specification will be changed
so that this feature is experimental. You will see a warning when
you make the first Ractor with `Ractor.new`.

I hope this feature can help programmers from thread-safety issues.
2020-09-03 21:11:06 +09:00
Masaki Matsushita 56dd578d7e IO.copy_stream: handle EOPNOTSUP instead of ENOTSUP 2020-08-29 16:10:58 +09:00
Masaki Matsushita 93df301048 IO.copy_stream: handle ENOTSUP on copy_file_range(2)
fallback to other methods on ENOTSUP.
some RedHat kernels may return ENOTSUP on an NFS mount.
[Feature #16965]
2020-08-29 15:38:07 +09:00
Peter Zhu 166cacc505
Fix corruption in ARGF.inplace
Extension string stored in `ARGF.inplace` is created using an api
designed for C string constants to create a Ruby string that
points at another Ruby string. When the original string is swept,
the extension string gets corrupted.

Reproduction script (on MacOS):

```ruby
#!/usr/bin/ruby -pi.bak

BEGIN {
  GC.start(full_mark: true)
  arr = []
  1000000.times do |x|
    arr << "fooo#{x}"
  end
}

puts "hello"
```

Co-Authored-By: Matt Valentine-House <31869+eightbitraptor@users.noreply.github.com>
2020-08-12 17:54:09 +09:00
Nobuyoshi Nakada d2bf6133f6
Remove trailing spaces [ci skip] 2020-07-20 13:34:16 +09:00
Samuel Williams f3462d99a3 Rename `rb_current_thread_scheduler` to `rb_thread_scheduler_if_nonblocking`.
Correctly capture thread before releasing GVL and pass as argument to
`rb_thread_scheduler_if_nonblocking`.
2020-07-20 13:20:58 +12:00
卜部昌平 de3e931df7 add UNREACHABLE_RETURN
Not every compilers understand that rb_raise does not return.  When a
function does not end with a return statement, such compilers can issue
warnings.  We would better tell them about reachabilities.
2020-06-29 11:05:41 +09:00
卜部昌平 9e92292e30 rb_io_modestr_fmode: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
2020-06-29 11:05:41 +09:00
卜部昌平 0e4ee71546 rb_io_each_codepoint: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
2020-06-29 11:05:41 +09:00
Nobuyoshi Nakada 6f167da65b
Fixed a variable name [Bug #16903]
Fix up of 0e3b0fcdba

From: fd0 (Daisuke Fujimura)
2020-05-21 10:47:41 +09:00
Samuel Williams 0e3b0fcdba
Thread scheduler for light weight concurrency. 2020-05-14 22:10:55 +12:00
卜部昌平 9e41a75255 sed -i 's|ruby/impl|ruby/internal|'
To fix build failures.
2020-05-11 09:24:08 +09:00
卜部昌平 d7f4d732c1 sed -i s|ruby/3|ruby/impl|g
This shall fix compile errors.
2020-05-11 09:24:08 +09:00
Nobuyoshi Nakada b5132d91c0
Refactored rb_readwrite_syserr_fail
* renamed argument `writable` as `waiting`
* hosited out creating and raising exception
* turned into a `switch`
2020-04-17 14:08:54 +09:00
Nobuyoshi Nakada 155f64e3c4
Raise EPIPE at broken pipe for the backward compatibility
Instead of SignalException for SIGPIPE, raise `Errno::EPIPE` with
instance variable `signo` and re-send that signal at exit.
[Feature #14413]
2020-04-15 21:05:39 +09:00
Nobuyoshi Nakada e6551d835f PAGER without fork&exec too [Feature #16754] 2020-04-12 14:58:13 +09:00
Nobuyoshi Nakada 6f28ebd585
Silence broken pipe error messages on STDOUT [Feature #14413]
Raise `SignalException` for SIGPIPE to abort when EPIPE occurs.
2020-04-11 09:30:19 +09:00
Nobuyoshi Nakada 63a5412db7
Make `#inspect` interruptible in `Kernel#p`
Only writing the inspected result and a newline is
uninterruptible.
2020-04-10 10:52:33 +09:00
Nobuyoshi Nakada 614d816a1f
Constified writev function family 2020-04-10 10:37:15 +09:00
卜部昌平 9e6e39c351
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
2020-04-08 13:28:13 +09:00
Jeremy Evans e1e4ea8fa9 Set external encoding correctly for File.open('f', FILE::BINARY) on Windows
Previously, the external encoding was only set correctly for
File::BINARY if keyword arguments were provided.  This copies
the logic for the keyword arguments case to the no keyword
arguments case.  Possibly it should be refactored into a
separate function.

Fixes [Bug #16737]
2020-03-27 11:31:19 -07:00
Jeremy Evans 54499d7810 Remove support for passing nil to IO#ungetc
Fixes [Bug #13675]
2020-02-27 10:17:54 -08:00
Nobuyoshi Nakada 8a7e0aaaef
Warn non-nil `$/` [Feature #14240] 2020-02-23 13:37:40 +09:00