Nokia N97 SDK
Example Applications Guide

Example application to simulate Active Object using Open C APIs

1. About this Example
2. Prerequisites
3. Design and Implementation


1. About this Example

This example illustrates how to simulate Symbian active object functionality using pthread and message queue. Here, each thread registered async handler with Asynchronous handler thread. Once Async Handler thread received any event, it calls the corresponding register handler.

Users can follow this pattern for the following situation:

  1. Wants to do somethig specific to some events, where events can be send by threads within the same process or by different processes. Only restriction is, async handler shouldn't do any time consuming activities.
  2. Symbian developers can treat each thread as an Active Ojbect (AO) and Async event handling thread as Active Schedular (AS). Here, installation for message event done through registration.
  3. Can register multiple async event handler.

Specifically, this model can be used where threads/processes are doing something but these entities wants to do something specific based on events where events may be generated by some other entities. Events are basically different triggers to the system. For example, one thread creates one buffer and pass the same to other thread. At the same time these threads are also doing some other activity. When buffer is full, that time other thread can send one event and async event handler will call the corresponding registered handler to handle the buffer.


2. Prerequisites

This example requires a familiarity with POSIX standard C APIs, and access to Open C documentation.


3. Design and Implementation

3.1 Capabilities

The program capabilities are defined in simulateactiveobject.mmp file: CAPABILITY NONE.

3.2 Static structure

SAsyncParameter used to pass all parameters, required during registration. AsyncContainerNode used as link list node. SAsyncContainer contained total number of registered processes and pointer to the link list. SEventMsg used to send short messages to other processes.

3.3 Application Launching

The application is simple console based application. It has its own default icon and can be launched from the UI both in the emulator and in the device.

The application can be launched by:

  1. Executing simulateactiveobject from eshell.
  2. Clicking default icon with display text simulateactiveobject within the install folder launcher application.

3.3.1 Creating event handler threads

This application is used to prove the idea of async handling of event similar to Symbian Active Object. Application creates diffirent thread for handling different events (namely key/sound)

including one async event handling thread. Each event handling thread registered itself with async handler at thread entry point. Any thread can registered more than one event handler.

During execution any thread can post events and async event handler thread calls the corresponding registered async event handler method.


© Nokia 2009

Back to top