Using One Parallel Result and Canceling the Rest
A parallel search can accept one result and stop unnecessary remaining work when its specification allows any valid witness.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace competing matches
Two workers can find different valid positions. Returning whichever finishes first does not guarantee the earliest position in the input. First-match scanning defines that stronger rule.
Check effects of cancellation
Outstanding work may already have produced state changes. Verify cleanup and report the chosen result deliberately. Cooperative cancellation describes stopping at valid boundaries.[1]
Distinguish first completed result from earliest input match
Suppose two chunks each contain a match. The higher-index chunk finishes sooner. Returning it is allowed for an any-witness search, but an earliest-index contract may need to wait for earlier positions. See first-match scans.
Later chunk reports index 20 first
Earlier chunk later reports index 3
Any-witness answer can be 20
Earliest answer must be 3
Clean up remaining work once the chosen contract permits
Cancellation can be cooperative and leave workers briefly active. Check resource release and external effects. Test both a result found and complete absence.