Processing a list of atomic operations, allowing for interruptions
- by JDB
I'm looking for a design pattern that addresses the following situation:
There exists a list of tasks that must be processed.
Tasks may be added at any time.
Each task is wholly independent from all other tasks.
The order in which tasks are processed has no effect on the overall system or on the tasks themselves.
Every task must be processed once and only once.
The "main" process which launches the task processors may start and stop without warning. When stopped, the "main" process loses all in-memory data.
Obviously this is going to involve some state, but are there any design patterns which discuss where and how to maintain that state? Are there any relevant anti-patterns?
Named patterns are especially helpful so that we can discuss this topic with other organizations without having to describe the entire problem domain.