accel-gcthread 0.0.1.pre1

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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/lib/accel/gcthread.rb +47 -0
  4. metadata +45 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 72534ef8dc3c85e0499acc95a7469fc0ab91e67c
4
+ data.tar.gz: 8091eedca72250718aaee8542cf8aa85e6dac079
5
+ SHA512:
6
+ metadata.gz: c4c32ad3130f8575a97e6ff5765119f99988da52a9180b9ba8c22f3a92282af7b8784f820dec7b8ed83bddb9068c70e32a5ae199ad5d4364eda9049d13acf246
7
+ data.tar.gz: 62a12f40bf74fd2c058303f750cd70d3416cb8f836bf7a1592dc84b04226dbab37b43abca0d173f59720ccd5fcb36074b8c8844346ff1bd4fe71d1c8d4cc6917
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,47 @@
1
+ module Accel
2
+ module GCThread
3
+ @interval = 2
4
+ @procs = []
5
+
6
+ def self.setup(cond_proc, post_proc=nil, interval=nil)
7
+ h = {:cond => cond_proc, :post => post_proc}
8
+ @procs << h
9
+ if interval and @interval > interval
10
+ @interval = interval
11
+ end
12
+ h
13
+ end
14
+
15
+ def self.thread
16
+ @thread
17
+ end
18
+
19
+ def self.interval
20
+ @interval
21
+ end
22
+
23
+ def self.set_interval!(interval)
24
+ @interval = interval
25
+ end
26
+
27
+ @thread = Thread.start do
28
+ loop do
29
+ sleep(@interval)
30
+ @procs.each{|h|
31
+ begin
32
+ if h[:cond].call
33
+ GC.start
34
+ @procs.each{|h|
35
+ h[:post].call if h[:cond]
36
+ }
37
+ break
38
+ end
39
+ rescue => e
40
+ Thread.main.raise(e.exception, e.message, e.backtrace)
41
+ end
42
+ }
43
+ end
44
+ end
45
+
46
+ end
47
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: accel-gcthread
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre1
5
+ platform: ruby
6
+ authors:
7
+ - Takashi Tamura
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple Ruby-level GC thread used with other ruby-accel gems.
14
+ email: ''
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - LICENSE
20
+ - lib/accel/gcthread.rb
21
+ homepage: https://github.com/ruby-accel/accel-gcthread
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.1.0
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">"
37
+ - !ruby/object:Gem::Version
38
+ version: 1.3.1
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.5.1
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: A simple Ruby-level GC thread
45
+ test_files: []