Go.rb 0.1.2 → 0.1.3

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: a6fe5f1c1b557f606f2362f4a4208e3bb06708ad
4
- data.tar.gz: 4fd8bdfec39fb1af91232220a5109cf4646046ff
3
+ metadata.gz: 15835470aa1c2184c9588f685b18ebbb35924a3f
4
+ data.tar.gz: 28007c58af472a54ade8bf74bd30cb7878350174
5
5
  SHA512:
6
- metadata.gz: dd6c7fa53a8d2767ffc19456df9c31e89c528244d8f356fd4abe72199f3c0e38612deb30de1edb5f0642e86ec4b6eff70dd50a45f93245036f6678d47f417944
7
- data.tar.gz: c2143528ac47b7113ff49d3c2a2e931fa020fdff899536b1b4a7ae2437658346dc44237c9f506ab098eb6e1e310223fb068ec0cbaf0ff27d3fbf64fcb83975d1
6
+ metadata.gz: ce83cb8fd25c08e409580ac62375975c981981f538974e596fce73b5495063873b9fe264b9bbab5f59ae9965ead065eec5fc62f28c7ba043701efb6b1abffb34
7
+ data.tar.gz: b8459c81e1b6ea35fa9ae1ee8266d7c1b6d937106fa271135d5c96b4f5eefa0fda47022bf5a216993159463915ab8bef42a3aafbe229bdbae57ca829f300e8d1
data/Rakefile CHANGED
@@ -2,6 +2,8 @@ require "bundler/gem_tasks"
2
2
 
3
3
  require 'rake/testtask'
4
4
 
5
+ task default: %w[test]
6
+
5
7
  Rake::TestTask.new do |t|
6
8
  t.libs << "test"
7
9
  t.test_files = FileList['test/unit.rb']
@@ -28,4 +28,6 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_development_dependency "bundler"
30
30
  spec.add_development_dependency "rake"
31
+ spec.add_development_dependency "test-unit"
32
+ spec.add_development_dependency "coveralls"
31
33
  end
data/lib/go.rb CHANGED
@@ -2,7 +2,4 @@ require "go/version"
2
2
  require "go/concurrency/pool"
3
3
  require "go/goconfig"
4
4
  require "go/kernel"
5
-
6
- module Go
7
-
8
- end
5
+ require "go/engine"
@@ -31,7 +31,7 @@ module Go
31
31
  end
32
32
 
33
33
  def errored?
34
- @ex
34
+ !@ex.nil?
35
35
  end
36
36
 
37
37
  def get
@@ -11,7 +11,6 @@ module Go
11
11
  @growing = growing
12
12
  @workQueue = Queue.new
13
13
  @running = true
14
- @shutting_down = false
15
14
 
16
15
  initStatic() unless @growing
17
16
  end
@@ -37,7 +36,7 @@ module Go
37
36
  end
38
37
 
39
38
  def execute(&block)
40
- execute_proc(args, block)
39
+ return execute_proc(block)
41
40
  end
42
41
 
43
42
  def execute_proc(proc)
@@ -62,6 +61,7 @@ module Go
62
61
 
63
62
  def shutdown
64
63
  @running = false
64
+ @threads.each { |t| t.kill }
65
65
  end
66
66
 
67
67
  def max; @max end
@@ -0,0 +1,17 @@
1
+ module Go
2
+ class Engine
3
+
4
+ def initialize(max_size=10, growing=true)
5
+ @config = Go::Config.new(max_size, growing)
6
+ end
7
+
8
+ def go &block
9
+ @config.thread_pool.execute_proc block
10
+ end
11
+
12
+ def config
13
+ @config
14
+ end
15
+
16
+ end
17
+ end
@@ -1,12 +1,12 @@
1
1
  module Go
2
2
  class Config
3
3
 
4
- def initialize(max_threads)
4
+ def initialize(max_threads, growing = true)
5
5
  @threads = max_threads
6
- @pool = Go::CC::ThreadPool.new(max_threads)
6
+ @pool = Go::CC::ThreadPool.new(max_threads, growing)
7
7
  end
8
8
 
9
- def thread_count
9
+ def max_thread_count
10
10
  @threads
11
11
  end
12
12
 
@@ -14,8 +14,8 @@ module Go
14
14
  @pool
15
15
  end
16
16
 
17
- def self.create(max_threads = 10)
18
- @@config = Config.new(max_threads)
17
+ def self.create(max_threads = 10, growing = true)
18
+ @@config = Config.new(max_threads, growing)
19
19
  end
20
20
 
21
21
  def self.maybe_create(max_threads = 10)
@@ -1,3 +1,3 @@
1
1
  module Go
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Go.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - JacisNonsense
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-04 00:00:00.000000000 Z
11
+ date: 2015-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  description: "'Go' is a language that specializes in concurrency and control flow,
42
70
  but some people (myself included) don't like the choice of Syntax. Not only that,
43
71
  but these features are something that could be useful in other projects, hence why
@@ -55,6 +83,7 @@ files:
55
83
  - lib/go.rb
56
84
  - lib/go/concurrency/future.rb
57
85
  - lib/go/concurrency/pool.rb
86
+ - lib/go/engine.rb
58
87
  - lib/go/goconfig.rb
59
88
  - lib/go/kernel.rb
60
89
  - lib/go/version.rb