nakayoshi_fork 0.0.3 → 0.0.4

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
  SHA1:
3
- metadata.gz: 4f6e04dda5d77eb372c3ac23d3abc2bea690bac4
4
- data.tar.gz: 0b79fabeb0e0586cdb061d48a19c9966476210bd
3
+ metadata.gz: ae7c045fc5fc03c87c17f196fb1d8acd29257923
4
+ data.tar.gz: 1c8a712d346d107143b15700b719166793f8f8d0
5
5
  SHA512:
6
- metadata.gz: 82ad9ab1312d370970ae07ca3b03ff18ee319b9e757a93b034d03103cbc78c7c4f113192b12766776dd4080046c6eb40b25122476042e5eb100a2be445f5eb65
7
- data.tar.gz: d4d6acce210abe0b72ed2b9a8572bd5951c86eaee4654992d06f654d244a00aa1425975af5e5df722215306cc9cef9881dbd377347853a77d59e7955f67726a1
6
+ metadata.gz: b72d9e1912591fca5e341884f19ec81fbb571b5eaf96e2892c80e8c06e3caedb842591d996d828a1e683f22ead1f0c17e38b1e748064fb5c559cbbb9cdf329c5
7
+ data.tar.gz: 3ae660567b7106413947aaba260c6ebcb49fa7fabb9f19b29716e96f5eddfb76cb817d6b3664f4980ed765c2a777d45e8a28ad9ff009024152c302b137d83030
data/.gitignore CHANGED
File without changes
data/Gemfile CHANGED
File without changes
File without changes
data/README.md CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- You only need to `require "nakayoshi-fork"`.
23
+ You only need to `require "nakayoshi_fork"`.
24
24
 
25
25
  If you want to disable nakayoshi-fork, then use `fork(nakayoshi: false)` or `fork(cow_friendly: false)`.
26
26
 
data/Rakefile CHANGED
File without changes
@@ -1,30 +1,30 @@
1
1
  require "nakayoshi_fork/version"
2
2
 
3
3
  module NakayoshiFork
4
- def fork(nakayoshi: true, cow_friendly: true, &b)
5
- if nakayoshi && cow_friendly
6
- h = {}
7
- 4.times{ # maximum 4 times
8
- GC.stat(h)
9
- live_slots = h[:heap_live_slots] || h[:heap_live_slot]
10
- old_objects = h[:old_objects] || h[:old_object]
11
- remwb_unprotects = h[:remembered_wb_unprotected_objects] || h[:remembered_shady_object]
12
- young_objects = live_slots - old_objects - remwb_unprotects
4
+ module Behavior
5
+ def fork(nakayoshi: true, cow_friendly: true, &b)
6
+ if nakayoshi && cow_friendly
7
+ h = {}
8
+ 4.times{ # maximum 4 times
9
+ GC.stat(h)
10
+ live_slots = h[:heap_live_slots] || h[:heap_live_slot]
11
+ old_objects = h[:old_objects] || h[:old_object]
12
+ remwb_unprotects = h[:remembered_wb_unprotected_objects] || h[:remembered_shady_object]
13
+ young_objects = live_slots - old_objects - remwb_unprotects
13
14
 
14
- # p [[live_slots, old_objects, remwb_unprotects], [young_objects]]
15
+ break if young_objects < live_slots / 10
15
16
 
16
- break if young_objects < live_slots / 10
17
+ disabled = GC.enable
18
+ GC.start(full_mark: false)
19
+ GC.disable if disabled
20
+ }
21
+ end
17
22
 
18
- disabled = GC.enable
19
- GC.start(full_mark: false)
20
- GC.disable if disabled
21
- }
22
- end
23
-
24
- super(&b)
25
- end if GC.method(:start).arity != 0
23
+ super(&b)
24
+ end if GC.method(:start).arity != 0
25
+ end
26
26
  end
27
27
 
28
28
  class Object
29
- prepend NakayoshiFork
29
+ prepend NakayoshiFork::Behavior
30
30
  end
@@ -1,3 +1,3 @@
1
1
  module NakayoshiFork
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nakayoshi_fork
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koichi Sasada
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-21 00:00:00.000000000 Z
11
+ date: 2018-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  version: '0'
74
74
  requirements: []
75
75
  rubyforge_project:
76
- rubygems_version: 2.5.0
76
+ rubygems_version: 2.6.11
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: nakayoshi_fork gem solves CoW friendly problem on MRI 2.2 and later.