Symbian OS development manual 9 basic concepts of Active Object

Source: Internet
Author: User

We talked about the use of multithreading in Symbian OS. This is a framework that is more frequently used in Symbian OS: Active Object (AO ).
Multithreading is widely used in traditional programs, but it is not necessarily a good choice for small devices with limited resources. Through the routine of the class, we can see that each thread needs to allocate a certain amount of memory. If all asynchronous operations are done through multithreading, it will be a great burden on the system. AO is designed to process asynchronous operations in the same thread.

AO works under the coordination of activescheduler (AS). When an AO sends an asynchronous request, the request function returns immediately. AO can continue to run or wait. After the asynchronous operation is complete, the as will be notified, and then it calls the runl function in the corresponding AO. Therefore, the common use of AO is to create a request function for asynchronous operations and then process the operation results in runl. For example, if we have a socket that needs to read some data from the network and then output the data, we need:

One request function:
Void MYA: requestreceive ()
{
Isocket. Recv (ibuf,..., istatus );
}

And runl:
Void MYA: runl ()
{
Iconsole-> printf (ibuf );
}

When using this Ao, You can first call requestreceive () and then continue to do other things. After the socket is read, as will call the runl of this Ao, then the accepted data will be printed. Of course, to actually use ao in a program, we still need to learn a lot. Now you only need to have a conceptual understanding of AO.

The following is an illustration in newlc, which basically outlines the active object framework:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.