There is a stream of events handled by an expensive algorithm that runs for a very long time. The results for all events, except for the last (at every moment), are not of interest. I want to handle the event, asynchronously interrupting the processing of previous events every time a new one arrives.
Are there any good templates or methods for this?
I thought:
- participants (without cancellation)
- futures (no cancellation)
- (it is not clear how to choose the last event, and they are usually difficult)
- thread pools (requires a custom solution, not a Scala method?)
I prefer to select pools with a custom intermittent task (not yet developed). Are there any better options in Scala? If not, how do I accomplish my task?
source
share