File tree 1 file changed +5
-4
lines changed
1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -2208,21 +2208,22 @@ module Array =
2208
2208
[<CompiledName( " TryPick" ) >]
2209
2209
let tryPick chooser ( array : _ array ) =
2210
2210
checkNonNull " array" array
2211
- let mutable chosen = None
2211
+ let allChosen = System.Collections.Concurrent.ConcurrentDictionary ()
2212
2212
2213
- let _pResult =
2213
+ let pResult =
2214
2214
Parallel.For(
2215
2215
0 ,
2216
2216
array.Length,
2217
2217
( fun i pState ->
2218
2218
match chooser array[ i] with
2219
2219
| None -> ()
2220
2220
| chosenElement ->
2221
- ignore ( Interlocked.Exchange (& chosen , chosenElement))
2221
+ allChosen [ i ] <- chosenElement
2222
2222
pState.Break())
2223
2223
)
2224
2224
2225
- chosen
2225
+ if pResult.LowestBreakIteration.HasValue then allChosen[ int ( pResult.LowestBreakIteration.GetValueOrDefault())]
2226
+ else None
2226
2227
2227
2228
[<CompiledName( " Choose" ) >]
2228
2229
let choose chooser ( array : 'T array ) =
You can’t perform that action at this time.
0 commit comments