async 1.28.7 → 1.28.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/async/node.rb +25 -20
- data/lib/async/reactor.rb +1 -1
- data/lib/async/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bfd6d656f9d5f891985de61ab428bafe452148e85cdc9d3ff43deec90e17f5e
|
4
|
+
data.tar.gz: 4c402e7fb08a04356ae96672598e5c196774bdc0c95462d6f32620796977cd64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96b328f71cd892be4d9ecb677911054dad649b2e1115d5c6a92aa6c616295e66c969d964b3127797c9209f38cdb44962e364e4d8a0462e14d5da13bf51b1c4a5
|
7
|
+
data.tar.gz: 919265a3a3c5a8a1e512548860fb8a37641016c0a25f7322330f2560f651a1991144c632ef12c8e87410810f8fe2e42df67a9a5a7c98965e37f414ad515baddb
|
data/lib/async/node.rb
CHANGED
@@ -24,6 +24,7 @@ module Async
|
|
24
24
|
# A double linked list.
|
25
25
|
class List
|
26
26
|
def initialize
|
27
|
+
# The list behaves like a list node, so @tail points to the next item (the first one) and head points to the previous item (the last one). This may be slightly confusing but it makes the interface more natural.
|
27
28
|
@head = nil
|
28
29
|
@tail = nil
|
29
30
|
@size = 0
|
@@ -36,21 +37,21 @@ module Async
|
|
36
37
|
|
37
38
|
# Inserts an item at the end of the list.
|
38
39
|
def insert(item)
|
39
|
-
unless @
|
40
|
-
@head = item
|
40
|
+
unless @tail
|
41
41
|
@tail = item
|
42
|
+
@head = item
|
42
43
|
|
43
44
|
# Consistency:
|
44
45
|
item.head = nil
|
45
46
|
item.tail = nil
|
46
47
|
else
|
47
|
-
@
|
48
|
-
item.head = @
|
48
|
+
@head.tail = item
|
49
|
+
item.head = @head
|
49
50
|
|
50
51
|
# Consistency:
|
51
52
|
item.tail = nil
|
52
53
|
|
53
|
-
@
|
54
|
+
@head = item
|
54
55
|
end
|
55
56
|
|
56
57
|
@size += 1
|
@@ -59,14 +60,14 @@ module Async
|
|
59
60
|
end
|
60
61
|
|
61
62
|
def delete(item)
|
62
|
-
if @
|
63
|
-
@
|
63
|
+
if @tail.equal?(item)
|
64
|
+
@tail = @tail.tail
|
64
65
|
else
|
65
66
|
item.head.tail = item.tail
|
66
67
|
end
|
67
68
|
|
68
|
-
if @
|
69
|
-
@
|
69
|
+
if @head.equal?(item)
|
70
|
+
@head = @head.head
|
70
71
|
else
|
71
72
|
item.tail.head = item.head
|
72
73
|
end
|
@@ -79,15 +80,17 @@ module Async
|
|
79
80
|
return self
|
80
81
|
end
|
81
82
|
|
82
|
-
def each
|
83
|
+
def each(&block)
|
83
84
|
return to_enum unless block_given?
|
84
85
|
|
85
|
-
|
86
|
-
while
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
86
|
+
current = self
|
87
|
+
while node = current.tail
|
88
|
+
yield node
|
89
|
+
|
90
|
+
# If the node has deleted itself or any subsequent node, it will no longer be the next node, so don't use it for continued traversal:
|
91
|
+
if current.tail.equal?(node)
|
92
|
+
current = node
|
93
|
+
end
|
91
94
|
end
|
92
95
|
end
|
93
96
|
|
@@ -100,19 +103,19 @@ module Async
|
|
100
103
|
end
|
101
104
|
|
102
105
|
def first
|
103
|
-
@
|
106
|
+
@tail
|
104
107
|
end
|
105
108
|
|
106
109
|
def last
|
107
|
-
@
|
110
|
+
@head
|
108
111
|
end
|
109
112
|
|
110
113
|
def empty?
|
111
|
-
@
|
114
|
+
@tail.nil?
|
112
115
|
end
|
113
116
|
|
114
117
|
def nil?
|
115
|
-
@
|
118
|
+
@tail.nil?
|
116
119
|
end
|
117
120
|
end
|
118
121
|
|
@@ -276,6 +279,8 @@ module Async
|
|
276
279
|
if child.finished?
|
277
280
|
delete_child(child)
|
278
281
|
else
|
282
|
+
# In theory we don't need to do this... because we are throwing away the list. However, if you don't correctly update the list when moving the child to the parent, it foobars the enumeration, and subsequent nodes will be skipped, or in the worst case you might start enumerating the parents nodes.
|
283
|
+
delete_child(child)
|
279
284
|
parent.add_child(child)
|
280
285
|
end
|
281
286
|
end
|
data/lib/async/reactor.rb
CHANGED
data/lib/async/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.28.
|
4
|
+
version: 1.28.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: console
|