e-threadpool 1.0.0 → 1.0.1

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.
data/README.md CHANGED
@@ -7,30 +7,35 @@ Threadpool is the "threadpool pattern" implemented in ruby. It's a compact but r
7
7
  - MRI and JRuby are supported.
8
8
 
9
9
  ## Install
10
- gem install e-threadpool
11
- or edit Gemfile
10
+ Edit `Gemfile`
11
+
12
12
  ...
13
13
  gem 'e-threadpool'
14
14
  ...
15
15
 
16
+ or
16
17
 
17
- ## Example
18
- require 'threadpool'
19
-
20
- class TestJob < Job
21
- def run
22
- puts "hello"
23
- end
24
- end
25
-
26
- threadpool = Threadpool::Threadpool.new
27
- 100.times.each do
28
- # threadpool auto-executes the job after loaded
29
- threadpool.load(TestJob.new)
30
- end
31
-
32
- # shutdown will wait until all jobs are finished
33
- threadpool.shutdown
18
+ gem install e-threadpool
34
19
 
35
- ## LICENSE
36
- MIT LICENSE, please refer to the LICENSE file.
20
+ ## Example
21
+ ```ruby
22
+ require 'threadpool'
23
+
24
+ class TestJob < Job
25
+ def run
26
+ puts "hello"
27
+ end
28
+ end
29
+
30
+ threadpool = Threadpool::Threadpool.new
31
+ 100.times.each do
32
+ # threadpool auto-executes the job after loaded
33
+ threadpool.load(TestJob.new)
34
+ end
35
+
36
+ # shutdown will wait until all jobs are finished
37
+ threadpool.shutdown
38
+ ```
39
+
40
+ ## License
41
+ MIT LICENSE, please refer to the LICENSE file.
data/lib/threadpool.rb CHANGED
@@ -2,4 +2,5 @@ $: << File.dirname(__FILE__)
2
2
 
3
3
  require 'threadpool/worker'
4
4
  require 'threadpool/core'
5
- require 'threadpool/job'
5
+ require 'threadpool/job'
6
+ include Threadpool
@@ -1,21 +1,19 @@
1
1
  require File.dirname(__FILE__) + '/../lib/threadpool'
2
2
  require 'test/unit'
3
3
 
4
- include Threadpool
5
-
6
4
  class TestJob < Job
7
5
  # NOTE: Mutext synchronize is a must, or the result might be unpredictable.
8
6
  @@m = Mutex.new
9
-
7
+
10
8
  def run
11
9
  @@m.synchronize do
12
10
  @args[0][0] += 1
13
- end
11
+ end
14
12
  end
15
13
  end
16
14
 
17
15
  class TestThreadpool < Test::Unit::TestCase
18
-
16
+
19
17
  def test_sync
20
18
  # arguments are init_workers, max_workers, timeout_secs. [OPTIONAL]
21
19
  threadpool = Threadpool::Threadpool.new(8, 22, 5)
@@ -32,4 +30,4 @@ class TestThreadpool < Test::Unit::TestCase
32
30
  threadpool.load(TestJob.new(sum))
33
31
  assert_equal(5000, sum[0])
34
32
  end
35
- end
33
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: e-threadpool
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: