5.2. Asynchronous Controller

Intent

Encapsulate a finite state machine within an active object to efficiently control a modest set of related asynchronous sub-tasks.

AKA

None known

5.2.1. Problem

5.2.1.1. Context

You have a single overall task that you wish to perform that requires a modest set of asynchronous requests, or sub-tasks, to be performed in a prescribed order.

5.2.1.2. Summary
  • You wish to keep your thread responsive to higher-priority event signals, such as those from end user events, whilst the overall task is being performed.

  • You wish to reduce your maintenance costs by encapsulating the control of which sub-task is performed next within a single class so that future changes only need to be done in this one place.

  • You wish to reduce the amount of RAM used by your software, for example by reducing the number of threads running in your process and by minimizing the code size of your solution.

  • You wish to reduce your maintenance costs by reducing the time that you spend debugging your software.

  • You wish to reduce the time that you need to spend testing your software looking for defects.

5.2.1.3. Description

If you've read Active Objects (see page 133), then your first question is going to be: 'What's the difference between a task and a sub-task?'. This is a question of granularity but the essence is that a task is something that other parts of your software are interested in completing whilst sub-tasks are the internal steps needed to achieve that end. Hence no other ...

Get Common Design Patterns for Symbian OS: The Foundations of Smartphone Software now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.