concurrent-ruby-edge 0.1.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +284 -0
- data/lib/concurrent-edge.rb +11 -0
- data/lib/concurrent/actor.rb +98 -0
- data/lib/concurrent/actor/behaviour.rb +143 -0
- data/lib/concurrent/actor/behaviour/abstract.rb +51 -0
- data/lib/concurrent/actor/behaviour/awaits.rb +21 -0
- data/lib/concurrent/actor/behaviour/buffer.rb +56 -0
- data/lib/concurrent/actor/behaviour/errors_on_unknown_message.rb +12 -0
- data/lib/concurrent/actor/behaviour/executes_context.rb +17 -0
- data/lib/concurrent/actor/behaviour/linking.rb +83 -0
- data/lib/concurrent/actor/behaviour/pausing.rb +123 -0
- data/lib/concurrent/actor/behaviour/removes_child.rb +16 -0
- data/lib/concurrent/actor/behaviour/sets_results.rb +37 -0
- data/lib/concurrent/actor/behaviour/supervising.rb +39 -0
- data/lib/concurrent/actor/behaviour/terminates_children.rb +14 -0
- data/lib/concurrent/actor/behaviour/termination.rb +74 -0
- data/lib/concurrent/actor/context.rb +167 -0
- data/lib/concurrent/actor/core.rb +220 -0
- data/lib/concurrent/actor/default_dead_letter_handler.rb +9 -0
- data/lib/concurrent/actor/envelope.rb +41 -0
- data/lib/concurrent/actor/errors.rb +27 -0
- data/lib/concurrent/actor/internal_delegations.rb +59 -0
- data/lib/concurrent/actor/public_delegations.rb +40 -0
- data/lib/concurrent/actor/reference.rb +106 -0
- data/lib/concurrent/actor/root.rb +37 -0
- data/lib/concurrent/actor/type_check.rb +48 -0
- data/lib/concurrent/actor/utils.rb +10 -0
- data/lib/concurrent/actor/utils/ad_hoc.rb +27 -0
- data/lib/concurrent/actor/utils/balancer.rb +43 -0
- data/lib/concurrent/actor/utils/broadcast.rb +52 -0
- data/lib/concurrent/actor/utils/pool.rb +54 -0
- data/lib/concurrent/agent.rb +289 -0
- data/lib/concurrent/channel.rb +6 -0
- data/lib/concurrent/channel/blocking_ring_buffer.rb +82 -0
- data/lib/concurrent/channel/buffered_channel.rb +87 -0
- data/lib/concurrent/channel/channel.rb +19 -0
- data/lib/concurrent/channel/ring_buffer.rb +65 -0
- data/lib/concurrent/channel/unbuffered_channel.rb +39 -0
- data/lib/concurrent/channel/waitable_list.rb +48 -0
- data/lib/concurrent/edge/atomic_markable_reference.rb +184 -0
- data/lib/concurrent/edge/future.rb +1226 -0
- data/lib/concurrent/edge/lock_free_stack.rb +85 -0
- metadata +110 -0
@@ -0,0 +1,85 @@
|
|
1
|
+
module Concurrent
|
2
|
+
module Edge
|
3
|
+
class LockFreeStack < Synchronization::Object
|
4
|
+
|
5
|
+
class Node
|
6
|
+
attr_reader :value, :next_node
|
7
|
+
|
8
|
+
def initialize(value, next_node)
|
9
|
+
@value = value
|
10
|
+
@next_node = next_node
|
11
|
+
end
|
12
|
+
|
13
|
+
singleton_class.send :alias_method, :[], :new
|
14
|
+
end
|
15
|
+
|
16
|
+
class Empty < Node
|
17
|
+
def next_node
|
18
|
+
self
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
EMPTY = Empty[nil, nil]
|
23
|
+
|
24
|
+
def initialize
|
25
|
+
@Head = AtomicReference.new EMPTY
|
26
|
+
ensure_ivar_visibility!
|
27
|
+
end
|
28
|
+
|
29
|
+
def empty?
|
30
|
+
@Head.get.equal? EMPTY
|
31
|
+
end
|
32
|
+
|
33
|
+
def compare_and_push(head, value)
|
34
|
+
@Head.compare_and_set head, Node[value, head]
|
35
|
+
end
|
36
|
+
|
37
|
+
def push(value)
|
38
|
+
while true
|
39
|
+
head = @Head.get
|
40
|
+
return self if @Head.compare_and_set head, Node[value, head]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def peek
|
45
|
+
@Head.get
|
46
|
+
end
|
47
|
+
|
48
|
+
def compare_and_pop(head)
|
49
|
+
@Head.compare_and_set head, head.next_node
|
50
|
+
end
|
51
|
+
|
52
|
+
def pop
|
53
|
+
while true
|
54
|
+
head = @Head.get
|
55
|
+
return head.value if @Head.compare_and_set head, head.next_node
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def compare_and_clear(head)
|
60
|
+
@Head.compare_and_set head, EMPTY
|
61
|
+
end
|
62
|
+
|
63
|
+
def clear
|
64
|
+
while true
|
65
|
+
head = @Head.get
|
66
|
+
return false if head == EMPTY
|
67
|
+
return true if @Head.compare_and_set head, EMPTY
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
include Enumerable
|
72
|
+
|
73
|
+
def each
|
74
|
+
return to_enum unless block_given?
|
75
|
+
it = peek
|
76
|
+
until it.equal?(EMPTY)
|
77
|
+
yield it.value
|
78
|
+
it = it.next_node
|
79
|
+
end
|
80
|
+
self
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: concurrent-ruby-edge
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.pre2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jerry D'Antonio
|
8
|
+
- The Ruby Concurrency Team
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-06-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: concurrent-ruby
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.9.0.pre2
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.9.0.pre2
|
28
|
+
description: |
|
29
|
+
These features are under active development and may change frequently. They are expected not to
|
30
|
+
keep backward compatibility (there may also lack tests and documentation). Semantic versions will
|
31
|
+
be obeyed though. Features developed in `concurrent-ruby-edge` are expected to move to `concurrent-ruby` when final.
|
32
|
+
Please see http://concurrent-ruby.com for more information.
|
33
|
+
email:
|
34
|
+
- jerry.dantonio@gmail.com
|
35
|
+
- concurrent-ruby@googlegroups.com
|
36
|
+
executables: []
|
37
|
+
extensions: []
|
38
|
+
extra_rdoc_files:
|
39
|
+
- README.md
|
40
|
+
- LICENSE.txt
|
41
|
+
files:
|
42
|
+
- LICENSE.txt
|
43
|
+
- README.md
|
44
|
+
- lib/concurrent-edge.rb
|
45
|
+
- lib/concurrent/actor.rb
|
46
|
+
- lib/concurrent/actor/behaviour.rb
|
47
|
+
- lib/concurrent/actor/behaviour/abstract.rb
|
48
|
+
- lib/concurrent/actor/behaviour/awaits.rb
|
49
|
+
- lib/concurrent/actor/behaviour/buffer.rb
|
50
|
+
- lib/concurrent/actor/behaviour/errors_on_unknown_message.rb
|
51
|
+
- lib/concurrent/actor/behaviour/executes_context.rb
|
52
|
+
- lib/concurrent/actor/behaviour/linking.rb
|
53
|
+
- lib/concurrent/actor/behaviour/pausing.rb
|
54
|
+
- lib/concurrent/actor/behaviour/removes_child.rb
|
55
|
+
- lib/concurrent/actor/behaviour/sets_results.rb
|
56
|
+
- lib/concurrent/actor/behaviour/supervising.rb
|
57
|
+
- lib/concurrent/actor/behaviour/terminates_children.rb
|
58
|
+
- lib/concurrent/actor/behaviour/termination.rb
|
59
|
+
- lib/concurrent/actor/context.rb
|
60
|
+
- lib/concurrent/actor/core.rb
|
61
|
+
- lib/concurrent/actor/default_dead_letter_handler.rb
|
62
|
+
- lib/concurrent/actor/envelope.rb
|
63
|
+
- lib/concurrent/actor/errors.rb
|
64
|
+
- lib/concurrent/actor/internal_delegations.rb
|
65
|
+
- lib/concurrent/actor/public_delegations.rb
|
66
|
+
- lib/concurrent/actor/reference.rb
|
67
|
+
- lib/concurrent/actor/root.rb
|
68
|
+
- lib/concurrent/actor/type_check.rb
|
69
|
+
- lib/concurrent/actor/utils.rb
|
70
|
+
- lib/concurrent/actor/utils/ad_hoc.rb
|
71
|
+
- lib/concurrent/actor/utils/balancer.rb
|
72
|
+
- lib/concurrent/actor/utils/broadcast.rb
|
73
|
+
- lib/concurrent/actor/utils/pool.rb
|
74
|
+
- lib/concurrent/agent.rb
|
75
|
+
- lib/concurrent/channel.rb
|
76
|
+
- lib/concurrent/channel/blocking_ring_buffer.rb
|
77
|
+
- lib/concurrent/channel/buffered_channel.rb
|
78
|
+
- lib/concurrent/channel/channel.rb
|
79
|
+
- lib/concurrent/channel/ring_buffer.rb
|
80
|
+
- lib/concurrent/channel/unbuffered_channel.rb
|
81
|
+
- lib/concurrent/channel/waitable_list.rb
|
82
|
+
- lib/concurrent/edge/atomic_markable_reference.rb
|
83
|
+
- lib/concurrent/edge/future.rb
|
84
|
+
- lib/concurrent/edge/lock_free_stack.rb
|
85
|
+
homepage: http://www.concurrent-ruby.com
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 1.9.3
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 1.3.1
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.4.7
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: Edge features and additions to the concurrent-ruby gem.
|
109
|
+
test_files: []
|
110
|
+
has_rdoc:
|