I'm looking for a design pattern that addresses the following situation:

  1. There exists a list of tasks that must be processed.

  2. Tasks may be added at any time.

  3. Each task is wholly independent from all other tasks.

  4. The order in which tasks are processed has no effect on the overall system or on the tasks themselves.

  5. Every task must be processed once and only once.

  6. 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.

  • Sounds similar to this: en.wikipedia.org/wiki/Thread_pool_pattern – Doval Jun 3 '14 at 14:15
  • Thanks @Doval, I've found many patterns dealing with lists. The key is the last part - the "main" process might be interrupted (ie shutdown), meaning it will lose it's state. The next time it's started, it'll basically need to pick back up where it left off. – JDB still remembers Monica Jun 3 '14 at 14:20
  • 1
    You say the operations are atomic - what happens if the main shuts down mid task? – Bobson Jun 3 '14 at 14:36
  • Looking for patterns before you've figured out how to solve the problem is an anti-pattern. – Blrfl Jun 3 '14 at 14:38
  • 1
    If you aren't simply looking for a name, but actually for a solution, I'd suggest a database or persistent queue. – kdgregory Jun 3 '14 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.