ractor_io 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ractor_io.rb +19 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f67b66bca3a2c2c35ecc33c931f549f3f32b1e43be3f4587a27ac8c09a434aa7
|
4
|
+
data.tar.gz: b4adb978c7ba55dfec78994347632913a8cc51dc61f126db56a97469e58b3ac8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc14ca1b474fcc1320d766f4a6eb5716be770b99e3b757e013d2e68fd6f8a804d408a175643c1ce52a2cfa6016f6f89f76ec4b01a9917f75177b32c1d44d1864
|
7
|
+
data.tar.gz: e5ed4e5508b9966b3c858e3ffbaf9865ed13a6cceae4ab31abeef24a894ef27a1755ec587c4f4dc270f06a0043b63a1822abc872f11d670287fb48e59c73c418
|
data/lib/ractor_io.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
#
|
8
8
|
# # optional loop until the file is read
|
9
9
|
# loop do
|
10
|
-
#
|
10
|
+
# break if rio.ready?
|
11
11
|
# sleep 1
|
12
12
|
# end
|
13
13
|
#
|
@@ -15,7 +15,23 @@
|
|
15
15
|
class RactorIO
|
16
16
|
attr_reader :string
|
17
17
|
|
18
|
-
|
18
|
+
# move: if true, the Ractor will yield the loaded file using the `move` option of Ractor::yield.
|
19
|
+
# default: false
|
20
|
+
#
|
21
|
+
# NOTE: as of this writing, and having tested this against Ruby 3.1.x and
|
22
|
+
# 3.2.x, setting the `move` option to `true' for large amounts of data
|
23
|
+
# seems to cause a crash, at least on macOS. as a result this option is set
|
24
|
+
# to `false` by default, which will result in a lot of memory copying, and
|
25
|
+
# therefore increasing total memory consumption.
|
26
|
+
#
|
27
|
+
# In the meantime, see also https://github.com/jefflunt/thread_io -
|
28
|
+
# basically the same library as this, but using Threads only instead of
|
29
|
+
# Ractors, which has the advantage of sharing memory, if that's important to
|
30
|
+
# you. I haven't done extensive performance testing, so the perfornace
|
31
|
+
# difference between ractor_io and thread_io might not be very large for
|
32
|
+
# your particular use case.
|
33
|
+
def initialize(move: false)
|
34
|
+
@move = move
|
19
35
|
@ready = false
|
20
36
|
@string = nil
|
21
37
|
end
|
@@ -28,7 +44,7 @@ class RactorIO
|
|
28
44
|
@ready = false
|
29
45
|
@string = nil
|
30
46
|
r = Ractor.new do
|
31
|
-
Ractor.yield(IO.read(Ractor.receive), move:
|
47
|
+
Ractor.yield(IO.read(Ractor.receive), move: @move)
|
32
48
|
end
|
33
49
|
r.send(path)
|
34
50
|
@string = r.take
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ractor_io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Lunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: a small class that loads files in the background via a Ractor
|
14
14
|
email: jefflunt@gmail.com
|