concur 1.0.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +15 -41
- data/lib/concur.rb +0 -2
- metadata +3 -3
data/README.md
CHANGED
@@ -1,39 +1,11 @@
|
|
1
1
|
# Concur - A concurrency library for Ruby inspired by java.util.concurrency and Go (golang).
|
2
2
|
|
3
|
-
##
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
Concur.config.max_threads = 10
|
10
|
-
|
11
|
-
# fire off blocks using go
|
12
|
-
1.times do |i|
|
13
|
-
go do
|
14
|
-
puts "hello #{i}"
|
15
|
-
sleep 2
|
16
|
-
puts "#{i} awoke"
|
17
|
-
puts "hhi there"
|
18
|
-
end
|
19
|
-
puts "done #{i}"
|
20
|
-
end
|
21
|
-
|
22
|
-
# Use channels to communicate
|
23
|
-
ch = Concur::Channel.new
|
24
|
-
20.times do |i|
|
25
|
-
go(ch) do |ch|
|
26
|
-
puts "hello channel #{i} #{ch}"
|
27
|
-
sleep 2
|
28
|
-
# push to channel
|
29
|
-
ch << "pushed #{i} to channel"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# Read from channel
|
34
|
-
ch.each do |x|
|
35
|
-
puts "Got #{x} from channel"
|
36
|
-
end
|
3
|
+
## Getting Started
|
4
|
+
|
5
|
+
Install gem:
|
6
|
+
|
7
|
+
```
|
8
|
+
gem install concur
|
37
9
|
```
|
38
10
|
|
39
11
|
## General Usage
|
@@ -46,7 +18,7 @@ end
|
|
46
18
|
times.times do |i|
|
47
19
|
future = executor.execute do
|
48
20
|
puts "hello #{i}"
|
49
|
-
"result #{i}"
|
21
|
+
"result #{i}" # this is what will be returned from the Future
|
50
22
|
end
|
51
23
|
jobs << future
|
52
24
|
end
|
@@ -57,6 +29,14 @@ end
|
|
57
29
|
puts "pooled_duration=" + pooled_duration.to_s
|
58
30
|
executor.shutdown
|
59
31
|
|
32
|
+
|
33
|
+
## Futures
|
34
|
+
|
35
|
+
A Future is what is returned from the execute method. Call `future.get` to get the results of the block
|
36
|
+
or the Callable object. If it's not finished, `get` will block until it is. `get` will also raise an Exception
|
37
|
+
if an Exception occurred during running.
|
38
|
+
|
39
|
+
|
60
40
|
## EventMachine / Non-blocking I/O
|
61
41
|
|
62
42
|
DEPRECATED!!
|
@@ -84,9 +64,3 @@ get similar performance (if not better) on a single thread as you can with multi
|
|
84
64
|
|
85
65
|
See https://github.com/appoxy/concur/blob/master/test/test_concur.rb for more examples.
|
86
66
|
|
87
|
-
## Futures
|
88
|
-
|
89
|
-
A Future is what is returned from the execute method. Call `future.get` to get the results of the block
|
90
|
-
or the Callable object. If it's not finished, `get` will block until it is. `get` will also raise an Exception
|
91
|
-
if an Exception occurred during running.
|
92
|
-
|
data/lib/concur.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: concur
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-25 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A concurrency library for Ruby inspired by java.util.concurrency and
|
15
15
|
Go (golang). By http://www.appoxy.com
|
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
53
|
version: '0'
|
54
54
|
requirements: []
|
55
55
|
rubyforge_project:
|
56
|
-
rubygems_version: 1.8.
|
56
|
+
rubygems_version: 1.8.25
|
57
57
|
signing_key:
|
58
58
|
specification_version: 3
|
59
59
|
summary: A concurrency library for Ruby inspired by java.util.concurrency and Go (golang).
|