gvltest 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24a4699b2118ba2457c7765d1e9460c0e333ef6edee72442ef83c988ab87fc61
4
- data.tar.gz: 12767cf773794fea581f5eca968304de6c0d5a4cfac54ceda7deb5136fcb6116
3
+ metadata.gz: b3099832fb7cf4b13b0a56e5c967d4b56940ceeb6484485674898eed70b5c717
4
+ data.tar.gz: f955e38ad859a6641d19e7902c94035fa90c8d2174a24116aca7aa45c313b0c3
5
5
  SHA512:
6
- metadata.gz: e039bc89f213882d47834b38f118b6969108842d2f1f7f74c90f11f5bef810b66aafefc234f531dcfebaf92335537b133d29313b967ca27d65829d1cde4b6638
7
- data.tar.gz: 566fd41089e3a155a8d1f86de05aeeab76aeaea9faa614dcae5d9137c9fd7160c7a0aee9deae8c6bb92f6e98f8956b53d93713a360d65ec8aeb9bd7793bd32e6
6
+ metadata.gz: ca4be5f938a7b9f0584c651ba4d309cdf4e1dff0f2f6b8c8572352bd177ac943f169a0669899fa47a4e99db23a212869fc94971d6ad5ac9a3deb991a349566d1
7
+ data.tar.gz: 4a5023ab815279ebd88aa94b61c3947845357ae720851ccd96861dd4e9123167449f1267655d151ad2d0b61910a8485cb1b65c562a39e7ab5c3ff4854039c426
data/Rakefile CHANGED
@@ -1,6 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/test_*.rb"]
10
+ end
11
+
4
12
  require "rake/extensiontask"
5
13
 
6
14
  task build: :compile
@@ -11,4 +19,4 @@ Rake::ExtensionTask.new("gvltest", GEMSPEC) do |ext|
11
19
  ext.lib_dir = "lib/gvltest"
12
20
  end
13
21
 
14
- task default: %i[clobber compile]
22
+ task default: %i[clobber compile test]
@@ -6,20 +6,38 @@
6
6
 
7
7
  static VALUE rb_mGVLTest;
8
8
 
9
- static VALUE sleep_holding_gvl(VALUE self, VALUE timev) {
10
- double time = NUM2DBL(timev);
11
- unsigned long long int ns = time * 1E9;
12
- struct timespec ts = { ns / 1000000000LL, ns % 1000000000LL };
13
-
9
+ static void durable_sleep(struct timespec ts) {
14
10
  int res;
15
11
  do {
16
12
  res = nanosleep(&ts, &ts);
17
13
  } while (res && errno == EINTR);
14
+ }
18
15
 
16
+ static VALUE sleep_holding_gvl(VALUE self, VALUE timev) {
17
+ double time = NUM2DBL(timev);
18
+ unsigned long long int ns = time * 1E9;
19
+ struct timespec ts = { ns / 1000000000LL, ns % 1000000000LL };
20
+ durable_sleep(ts);
19
21
  return timev;
20
22
  }
21
23
 
22
- static void *nop(void *) {
24
+ static void *sleep_without_gvl_i(void *tsv) {
25
+ struct timespec *ts = tsv;
26
+ durable_sleep(*ts);
27
+ return NULL;
28
+ }
29
+
30
+ static VALUE sleep_without_gvl(VALUE self, VALUE timev) {
31
+ double time = NUM2DBL(timev);
32
+ unsigned long long int ns = time * 1E9;
33
+ struct timespec ts = { ns / 1000000000LL, ns % 1000000000LL };
34
+
35
+ rb_thread_call_without_gvl(sleep_without_gvl_i, &ts, NULL, NULL);
36
+ return Qnil;
37
+ }
38
+
39
+
40
+ static void *nop(void *unused) {
23
41
  return NULL;
24
42
  }
25
43
 
@@ -33,5 +51,6 @@ Init_gvltest(void)
33
51
  {
34
52
  rb_mGVLTest = rb_define_module("GVLTest");
35
53
  rb_define_singleton_method(rb_mGVLTest, "sleep_holding_gvl", sleep_holding_gvl, 1);
54
+ rb_define_singleton_method(rb_mGVLTest, "sleep_without_gvl", sleep_without_gvl, 1);
36
55
  rb_define_singleton_method(rb_mGVLTest, "nogvl_nop", nogvl_nop, 0);
37
56
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GVLTest
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gvltest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Hawthorn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-01 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2024-06-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gvl_timing
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  description: Some test methods for experimenting with CRuby's GVL
14
42
  email:
15
43
  - john@hawthorn.email
@@ -49,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
77
  - !ruby/object:Gem::Version
50
78
  version: '0'
51
79
  requirements: []
52
- rubygems_version: 3.5.9
80
+ rubygems_version: 3.4.19
53
81
  signing_key:
54
82
  specification_version: 4
55
83
  summary: Some test methods for experimenting with CRuby's GVL