NickyMeuleman / nicky-blog

https://nickymeuleman.netlify.app/
GNU General Public License v3.0
14 stars 6 forks source link

feat(aoc2021-solver): allow cancelling while calculating #162

Closed NickyMeuleman closed 2 years ago

NickyMeuleman commented 2 years ago

allows cancelling an operation mid-calculation by calling .terminate() on the webworker and sending it to the withoutWorker state. There it immediately enters the withWorker state again that has a service that sets up and starts listening to a new worker.

If a day is chosen while calculating, terminate, set the new day immediately and send to withoutWorker state. If a file is chosen while calculating, terminate, add the file to a queue and send to withoutWorker state. Once the worker is ready end enters the idle state, that queue is checked. If a file is in there, it reads that file (goes to the readFile state).