forkner 1.1 → 1.2

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 +4 -4
  2. data/README.md +54 -7
  3. data/lib/forkner.rb +2 -3
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b52b5779f3a60718d88c8211ffef94cd28c6f0c4f2c6b5912e15548b271673b5
4
- data.tar.gz: 78ad9cbbe65fc736daef6ab882193f7a6b2ff2bd9ab1e4d9d7d45dce9ed49cf2
3
+ metadata.gz: 5cfc51f0c6ff1c5aad52b94e669c788d00ca61d268618229941e5f96e5f9e384
4
+ data.tar.gz: 90f35b9917c65ed2ca0884e66c73ce574c0365ea0d86a44a1a6221ed4870c4bd
5
5
  SHA512:
6
- metadata.gz: 050ae01b17dd141a6164f0748df4a9f0087b8199cc24291275e69b92664c47b8c53de227a877bdacfce1a915ba2b3c7d287bbc80f6f5d1ddea4790d5f12e8a85
7
- data.tar.gz: bd8a8bf7a164c6d1219b20c3b3ef6ba5c9b2e0e16a4ebbfe1779f87e1ad1253a02ac8f23feb7e8c32699cced346959dcc36a0b97babd3dd5357a9c0b6672f54c
6
+ metadata.gz: afd4a6b35e80f47838694bd38a9d0b658e6631acd093826bd8401662a041cef22ec18bd2a46a3723d264b1a37fc35fdbe84ab5634115c03c96607cadabd09ea3
7
+ data.tar.gz: 21caed2b5a0a6ed84ef87e7bb6c060a04675f92984e8f8af592641971fed49df6e37f64a2a622e2cd57baceebfc7b5f777cabe4ab20881f0e0e88b69bf113af1
data/README.md CHANGED
@@ -8,7 +8,19 @@ them when they finish.
8
8
  Consider a situation in which you need to run a bunch of parallel processes, but
9
9
  no more than five at a time. You might do that like this:
10
10
 
11
- @@code basic basic
11
+ ```ruby
12
+ require 'forkner'
13
+
14
+ Forkner.container(5) do |forkner|
15
+ 100.times do
16
+ forkner.child do
17
+ # do stuff in the child process
18
+ end
19
+ end
20
+ end
21
+
22
+ # we won't get to this point until all child processes are done
23
+ ```
12
24
 
13
25
  First we load the `forkner` gem. Then we call Forkner's container `method`. All
14
26
  child processes within `container` will completed before the method is done.
@@ -35,7 +47,23 @@ processes, finish the block with a value that can be stored as JSON.
35
47
 
36
48
  Consider this example:
37
49
 
38
- @@code retrieve retrieve
50
+ ```ruby
51
+ Forkner.container(5) do |forkner|
52
+ forkner.reaper() do |rv|
53
+ puts '-----'
54
+ puts rv['myrand']
55
+ puts rv['timestamp']
56
+ end
57
+
58
+ 10.times do
59
+ forkner.child do
60
+ myrand = rand()
61
+ timestamp = Time.now
62
+ {'myrand'=>myrand, 'timestamp'=>timestamp}
63
+ end
64
+ end
65
+ end
66
+ ```
39
67
 
40
68
  In this example, inside the `container` block we call the Forkner object's
41
69
  `reaper` method with a block. In that block we get a single parameter which
@@ -57,7 +85,25 @@ Forkner object and call its `child` method. Just be sure to call the `wait_all`
57
85
  method after all the child processes have been called. The following code does
58
86
  exactly the same thing as the previous example.
59
87
 
60
- @@code no-container no-container
88
+ ```ruby
89
+ forkner = Forkner.new(5)
90
+
91
+ forkner.reaper() do |rv|
92
+ puts '-----'
93
+ puts rv['myrand']
94
+ puts rv['timestamp']
95
+ end
96
+
97
+ 10.times do
98
+ forkner.child do
99
+ myrand = rand()
100
+ timestamp = Time.now
101
+ {'myrand'=>myrand, 'timestamp'=>timestamp}
102
+ end
103
+ end
104
+
105
+ forkner.wait_all
106
+ ```
61
107
 
62
108
  ## Install
63
109
 
@@ -72,7 +118,8 @@ mike@idocs.com
72
118
 
73
119
  ## History
74
120
 
75
- | version | date | notes |
76
- |---------|-------------|-----------------------------------------------|
77
- | 1.0 | Jan 7, 2020 | Initial upload. |
78
- | 1.1 | Jan 7, 2020 | Fixed some typos. No change to functionality. |
121
+ | version | date | notes |
122
+ |---------|--------------|------------------------------------------------------------------|
123
+ | 1.0 | Jan 7, 2020 | Initial upload. |
124
+ | 1.1 | Jan 7, 2020 | Fixed some typos. No changes to functionality. |
125
+ | 1.2 | Jan 19, 2020 | Fixed other documentation problems. No changes to functionality. |
@@ -14,9 +14,8 @@ class Forkner
14
14
  # to /tmp.
15
15
  attr_accessor :tmp_dir
16
16
 
17
- ##
18
- # Version 1.1
19
- VERSION = '1.1'
17
+ # version 1.2
18
+ VERSION = '1.2'
20
19
 
21
20
 
22
21
  #---------------------------------------------------------------------------
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forkner
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.1'
4
+ version: '1.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike O'Sullivan