![](https://csdnimg.cn/release/download_crawler_static/86604072/bg1.jpg)
Symbian OS: Active Objects
And The Active Scheduler
SYMBIAN OS
Version 1.0
August 26, 2004
![](https://csdnimg.cn/release/download_crawler_static/86604072/bg2.jpg)
Symbian OS: Active Objects And The Active Scheduler | 2
Legal Notice
Copyright © 2004 Nokia Corporation. All rights reserved.
Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation.
Other product and company names mentioned herein may be trademarks or trade
names of their respective owners.
Disclaimer
The information in this document is provided “as is,” with no warranties whatsoever,
including any warranty of merchantability, fitness for any particular purpose, or any
warranty otherwise arising out of any proposal, specification, or sample. Furthermore,
information provided in this document is preliminary, and may be changed substantially
prior to final release. This document is provided for informational purposes only.
Nokia Corporation disclaims all liability, including liability for infringement of any
proprietary rights, relating to implementation of information presented in this document.
Nokia Corporation does not warrant or represent that such use will not infringe such
rights.
Nokia Corporation retains the right to make changes to this specification at any time,
without notice.
License
A license is hereby granted to download and print a copy of this specification for
personal use only. No other license to any other intellectual property rights is granted
herein.
Version 1.0 | August 26, 2004
![](https://csdnimg.cn/release/download_crawler_static/86604072/bg3.jpg)
Symbian OS: Active Objects And The Active Scheduler | 3
Contents
1. Introduction ......................................................................................................... 5
1.1 Overview .........................................................................................................................5
1.2 Scope ..............................................................................................................................5
2. Understanding Multitasking in General ............................................................ 6
2.1 Multitasking Definitions ...................................................................................................6
2.2 Multitasking in Symbian OS ............................................................................................6
2.3 Client/Server Architecture and Asynchronous Methods .................................................7
3. Active Objects and the Active Scheduler ....................................................... 10
3.1 Motivation......................................................................................................................10
3.2 Active Objects ...............................................................................................................10
3.3 Active Scheduler ...........................................................................................................13
3.3.1 Using an own active scheduler.............................................................................13
3.3.2 How active objects are tracked ............................................................................14
3.4 Miscellaneous Issues ....................................................................................................15
3.4.1 Nested scheduler loop..........................................................................................16
3.4.2 Long-running tasks ...............................................................................................17
4. Active Object Example...................................................................................... 18
4.1 Constructing the Engine................................................................................................18
4.2 Using the Engine...........................................................................................................19
4.2.1 Looking up the IP..................................................................................................19
4.2.2 Connecting the socket ..........................................................................................21
4.2.3 Requesting the document.....................................................................................21
4.2.4 Reading the document .........................................................................................22
4.3 Engine Destruction........................................................................................................24
5. Design Issues .................................................................................................... 26
5.1 Strict Error Handling......................................................................................................26
5.2 Avoid Forcing Asynchronous Calls to Synchronous Calls ............................................27
6. Where To Go Next ............................................................................................. 28
7. References ......................................................................................................... 29
Appendix A. CAOExampleEngine Sources........................................................... 30
A.1 AOExampleEngine.h.....................................................................................................30
A.2 AOExampleEngine.cpp.................................................................................................32
Version 1.0 | August 26, 2004
![](https://csdnimg.cn/release/download_crawler_static/86604072/bg4.jpg)
Symbian OS: Active Objects And The Active Scheduler | 4
Change History
August 26, 2004 Version 1.0 Initial document release
Version 1.0 | August 26, 2004
![](https://csdnimg.cn/release/download_crawler_static/86604072/bg5.jpg)
Symbian OS: Active Objects And The Active Scheduler | 5
1. Introduction
1.1 Overview
Together, active objects and an active scheduler provide nonpreemptive multitasking,
which can be used instead of multithreading in Symbian OS. The benefits obtained with
active objects are programming simplicity and a more efficient CPU when comparing
usage of threads.
This document provides a general introduction to multitasking in Chapter 2. Chapter 3
briefly explains the Symbian OS approach to effective multitasking using active objects
and the active scheduler. An example active object implementation is introduced in
Chapter 4. Design issues related to active objects are discussed in Chapter 5, and
Chapter 6 lists references for further reading.
Note that there are two new mechanisms introduced in Symbian OS v8.0, Publish-and-
Subscribe and Message Queues. These allow information to be shared between threads
and processes more conveniently. They don't provide alternatives to threads and active
objects but may impact on architectural decisions in relation to client code running in a
multi-threaded environment. These two new mechanisms are not discussed further in
this document.
1.2 Scope
This document is intended for developers who are new to Symbian OS. However,
essential idioms in Symbian OS (such as naming and exception handling) should be
understood. The document also covers several issues that some professionals may find
helpful.
Version 1.0 | August 26, 2004