1
1
use super :: plumbing:: * ;
2
2
use super :: * ;
3
3
4
- use std:: sync:: atomic:: { AtomicBool , Ordering } ;
5
4
use std:: fmt:: { self , Debug } ;
6
5
use std:: marker:: PhantomData ;
7
6
use super :: private:: Try ;
@@ -53,12 +52,10 @@ impl<U, I, ID, F> ParallelIterator for TryFold<I, U, ID, F>
53
52
fn drive_unindexed < C > ( self , consumer : C ) -> C :: Result
54
53
where C : UnindexedConsumer < Self :: Item >
55
54
{
56
- let full = AtomicBool :: new ( false ) ;
57
55
let consumer1 = TryFoldConsumer {
58
56
base : consumer,
59
- fold_op : & self . fold_op ,
60
57
identity : & self . identity ,
61
- full : & full ,
58
+ fold_op : & self . fold_op ,
62
59
marker : PhantomData ,
63
60
} ;
64
61
self . base . drive_unindexed ( consumer1)
@@ -67,9 +64,8 @@ impl<U, I, ID, F> ParallelIterator for TryFold<I, U, ID, F>
67
64
68
65
struct TryFoldConsumer < ' c , U , C , ID : ' c , F : ' c > {
69
66
base : C ,
70
- fold_op : & ' c F ,
71
67
identity : & ' c ID ,
72
- full : & ' c AtomicBool ,
68
+ fold_op : & ' c F ,
73
69
marker : PhantomData < U > ,
74
70
}
75
71
@@ -93,12 +89,11 @@ impl<'r, U, T, C, ID, F> Consumer<T> for TryFoldConsumer<'r, U, C, ID, F>
93
89
base : self . base . into_folder ( ) ,
94
90
result : Ok ( ( self . identity ) ( ) ) ,
95
91
fold_op : self . fold_op ,
96
- full : self . full ,
97
92
}
98
93
}
99
94
100
95
fn full ( & self ) -> bool {
101
- self . full . load ( Ordering :: Relaxed ) || self . base . full ( )
96
+ self . base . full ( )
102
97
}
103
98
}
104
99
@@ -120,7 +115,6 @@ impl<'r, U, T, C, ID, F> UnindexedConsumer<T> for TryFoldConsumer<'r, U, C, ID,
120
115
struct TryFoldFolder < ' r , C , U : Try , F : ' r > {
121
116
base : C ,
122
117
fold_op : & ' r F ,
123
- full : & ' r AtomicBool ,
124
118
result : Result < U :: Ok , U :: Error > ,
125
119
}
126
120
@@ -136,9 +130,6 @@ impl<'r, C, U, F, T> Folder<T> for TryFoldFolder<'r, C, U, F>
136
130
let result = self . result . and_then ( |acc| {
137
131
fold_op ( acc, item) . into_result ( )
138
132
} ) ;
139
- if result. is_err ( ) {
140
- self . full . store ( true , Ordering :: Relaxed ) ;
141
- }
142
133
TryFoldFolder {
143
134
result : result,
144
135
..self
@@ -154,7 +145,7 @@ impl<'r, C, U, F, T> Folder<T> for TryFoldFolder<'r, C, U, F>
154
145
}
155
146
156
147
fn full ( & self ) -> bool {
157
- self . result . is_err ( ) || self . full . load ( Ordering :: Relaxed ) || self . base . full ( )
148
+ self . result . is_err ( ) || self . base . full ( )
158
149
}
159
150
}
160
151
@@ -208,12 +199,10 @@ impl<U, I, F> ParallelIterator for TryFoldWith<I, U, F>
208
199
fn drive_unindexed < C > ( self , consumer : C ) -> C :: Result
209
200
where C : UnindexedConsumer < Self :: Item >
210
201
{
211
- let full = AtomicBool :: new ( false ) ;
212
202
let consumer1 = TryFoldWithConsumer {
213
203
base : consumer,
214
204
item : self . item ,
215
205
fold_op : & self . fold_op ,
216
- full : & full,
217
206
} ;
218
207
self . base . drive_unindexed ( consumer1)
219
208
}
@@ -223,7 +212,6 @@ struct TryFoldWithConsumer<'c, C, U: Try, F: 'c> {
223
212
base : C ,
224
213
item : U :: Ok ,
225
214
fold_op : & ' c F ,
226
- full : & ' c AtomicBool ,
227
215
}
228
216
229
217
impl < ' r , U , T , C , F > Consumer < T > for TryFoldWithConsumer < ' r , C , U , F >
@@ -247,12 +235,11 @@ impl<'r, U, T, C, F> Consumer<T> for TryFoldWithConsumer<'r, C, U, F>
247
235
base : self . base . into_folder ( ) ,
248
236
result : Ok ( self . item ) ,
249
237
fold_op : self . fold_op ,
250
- full : self . full ,
251
238
}
252
239
}
253
240
254
241
fn full ( & self ) -> bool {
255
- self . full . load ( Ordering :: Relaxed ) || self . base . full ( )
242
+ self . base . full ( )
256
243
}
257
244
}
258
245
0 commit comments