Introduction to asynchronous programming

This document introduces the concept of asynchronous programming.

When a program requests a service, this service can be performed either synchronously or asynchronously.

A synchronous service is the normal pattern for function calls where the function returns and the service requested has either performed successfully or has failed and an error code returned.

An asynchronous service is requested by a function call but completion occurs later. Completion is indicated by a signal. Between the issue of the request and the signal, the request is said to be pending. The requesting program can do other processing while the request is pending or it can issue a wait. The operating system wakes the program up when completion of any of its pending requests is signalled.

A program may contain a number of independently-executing units, called threads. All programs have a primary thread, and may create other threads, possibly for providing or using asynchronous services.

If all threads are in a wait state, for example, waiting for user input, Symbian platform powers down as much as possible of the machine’s electronics. This results in battery savings and, consequently, a considerable extension of useful battery life.