File tree Expand file tree Collapse file tree 4 files changed +42
-0
lines changed Expand file tree Collapse file tree 4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ void zstd_ruby_streaming_decompress_init(void);
7
7
void
8
8
Init_zstdruby (void )
9
9
{
10
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
11
+ rb_ext_ractor_safe (true);
12
+ #endif
13
+
10
14
rb_mZstd = rb_define_module ("Zstd" );
11
15
zstd_ruby_init ();
12
16
zstd_ruby_streaming_compress_init ();
Original file line number Diff line number Diff line change 52
52
expect ( Zstd . decompress ( res ) ) . to eq ( 'abcdef' )
53
53
end
54
54
end
55
+
56
+ if Gem ::Version . new ( RUBY_VERSION ) >= Gem ::Version . new ( '3.0.0' )
57
+ describe 'Ractor' do
58
+ it 'should be supported' do
59
+ r = Ractor . new {
60
+ stream = Zstd ::StreamingCompress . new ( 5 )
61
+ stream << "abc" << "def"
62
+ res = stream . finish
63
+ }
64
+ expect ( Zstd . decompress ( r . take ) ) . to eq ( 'abcdef' )
65
+ end
66
+ end
67
+ end
55
68
end
56
69
Original file line number Diff line number Diff line change 32
32
end
33
33
end
34
34
35
+ if Gem ::Version . new ( RUBY_VERSION ) >= Gem ::Version . new ( '3.0.0' )
36
+ describe 'Ractor' do
37
+ it 'should be supported' do
38
+ r = Ractor . new {
39
+ cstr = Zstd . compress ( 'foo bar buzz' )
40
+ stream = Zstd ::StreamingDecompress . new
41
+ result = ''
42
+ result << stream . decompress ( cstr [ 0 , 5 ] )
43
+ result << stream . decompress ( cstr [ 5 , 5 ] )
44
+ result << stream . decompress ( cstr [ 10 ..-1 ] )
45
+ result
46
+ }
47
+ expect ( r . take ) . to eq ( 'foo bar buzz' )
48
+ end
49
+ end
50
+ end
35
51
end
36
52
Original file line number Diff line number Diff line change @@ -74,5 +74,14 @@ def to_str
74
74
expect ( Zstd . decompress ( DummyForDecompress . new ) ) . to eq ( 'abc' )
75
75
end
76
76
end
77
+
78
+ if Gem ::Version . new ( RUBY_VERSION ) >= Gem ::Version . new ( '3.0.0' )
79
+ describe 'Ractor' do
80
+ it 'should be supported' do
81
+ r = Ractor . new { Zstd . compress ( 'abc' ) }
82
+ expect ( Zstd . decompress ( r . take ) ) . to eq ( 'abc' )
83
+ end
84
+ end
85
+ end
77
86
end
78
87
You can’t perform that action at this time.
0 commit comments