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
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:
- 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.
- 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.
- 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.
This example requires a familiarity with POSIX standard C APIs, and access to Open C documentation.
The program capabilities are defined in simulateactiveobject.mmp file: CAPABILITY NONE.
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.
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:
- Executing simulateactiveobject from eshell.
- Clicking default icon with display text simulateactiveobject within the install folder launcher application.
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
|

|