blocking_sleep 0.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 +7 -0
- data/ext/blocking_sleep/blocking_sleep.c +33 -0
- data/ext/blocking_sleep/extconf.rb +6 -0
- data/lib/blocking_sleep.rb +9 -0
- metadata +71 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 49021b725fda32ecf2c48f697a26aa1d52caf1d428a49abda08e80d036446d7c
|
|
4
|
+
data.tar.gz: f6105859c43ad3dda70a43dbd90704cec6881529d7569dac5b9964c2b80e15a0
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4f6745ec91a7569d338bfafb1123792ce0e29b888d1feda6a5ceee644d59240b5ac98ea97b7fe9cd1df0d6105fe73636be78b506f71f8041ef8dbb38a48fe012
|
|
7
|
+
data.tar.gz: fe5d17257c6944d71cef1865f9f54b1d818b9d0d41ad256d8e9869146e60fe5f9db98b03dc8acbe6c0289f4886fa416103b03e43a7fc5912d292e6b822571f83
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#include <ruby.h>
|
|
2
|
+
#include <unistd.h>
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Call native sleep() function without releasing GVL.
|
|
6
|
+
* This blocks the entire Ruby VM, useful for testing thread behavior.
|
|
7
|
+
*/
|
|
8
|
+
static VALUE
|
|
9
|
+
blocking_sleep_sleep(VALUE self, VALUE seconds)
|
|
10
|
+
{
|
|
11
|
+
unsigned int sleep_time;
|
|
12
|
+
|
|
13
|
+
// Convert Ruby number to C unsigned int
|
|
14
|
+
sleep_time = NUM2UINT(seconds);
|
|
15
|
+
|
|
16
|
+
// Call native sleep() - this blocks without releasing GVL
|
|
17
|
+
sleep(sleep_time);
|
|
18
|
+
|
|
19
|
+
return Qnil;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
void
|
|
23
|
+
Init_blocking_sleep(void)
|
|
24
|
+
{
|
|
25
|
+
VALUE mBlockingSleep;
|
|
26
|
+
|
|
27
|
+
// Define BlockingSleep module
|
|
28
|
+
mBlockingSleep = rb_define_module("BlockingSleep");
|
|
29
|
+
|
|
30
|
+
// Define BlockingSleep.sleep method
|
|
31
|
+
rb_define_module_function(mBlockingSleep, "sleep", blocking_sleep_sleep, 1);
|
|
32
|
+
}
|
|
33
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require 'blocking_sleep/blocking_sleep'
|
|
2
|
+
|
|
3
|
+
# BlockingSleep module provides a native blocking sleep
|
|
4
|
+
# that doesn't release the GVL (Global VM Lock).
|
|
5
|
+
# This is useful for testing thread behavior and GVL interactions.
|
|
6
|
+
module BlockingSleep
|
|
7
|
+
VERSION = "0.1.0"
|
|
8
|
+
end
|
|
9
|
+
|
metadata
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: blocking_sleep
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Vladimir Polukhin
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: rake
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :development
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: rake-compiler
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :development
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
description: A simple C extension that provides blocking sleep without releasing GVL
|
|
41
|
+
email: vovanmozg@gmail.com
|
|
42
|
+
executables: []
|
|
43
|
+
extensions:
|
|
44
|
+
- ext/blocking_sleep/extconf.rb
|
|
45
|
+
extra_rdoc_files: []
|
|
46
|
+
files:
|
|
47
|
+
- ext/blocking_sleep/blocking_sleep.c
|
|
48
|
+
- ext/blocking_sleep/extconf.rb
|
|
49
|
+
- lib/blocking_sleep.rb
|
|
50
|
+
homepage: https://example.com
|
|
51
|
+
licenses:
|
|
52
|
+
- MIT
|
|
53
|
+
metadata: {}
|
|
54
|
+
rdoc_options: []
|
|
55
|
+
require_paths:
|
|
56
|
+
- lib
|
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 2.5.0
|
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
|
+
requirements:
|
|
64
|
+
- - ">="
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: '0'
|
|
67
|
+
requirements: []
|
|
68
|
+
rubygems_version: 3.6.8
|
|
69
|
+
specification_version: 4
|
|
70
|
+
summary: Native blocking sleep for Ruby thread experiments
|
|
71
|
+
test_files: []
|