"Android Source design mode"--Enjoy meta mode

Source: Internet
Author: User
Tags epoll message queue

NO1:

The enjoy meta-mode is an implementation of an object pool . The enjoy meta-mode is used to minimize memory usage and is suitable for scenarios where there may be a large number of duplicate objects, to cache shareable objects, to achieve object sharing, to avoid the effects of creating too many objects, which can improve performance, avoid memory removal, and so on.

No2:

the UI cannot be updated in a child thread . Because it is not possible for the UI to be updated in a child thread, the UI cannot be updated without its creation line thread.

No3:

(1) First constructs the Java layer's Looper object, and the Looper object creates the Java layer MessageQueue object in the constructor.

(2) The Java layer's MessageQueue constructor calls the Nativeinit function to initialize the nativemessagequeue of the native layer, The Nativemessagequeue constructor also creates a looper of the native layer and sets up a message mechanism through the pipeline and Epoll

(3) The native layer is built, converting the Nativemessagequeue object to an integer stored in the mptr of the Java layer MessageQueue

(4) Start the Java layer's message loop and continuously read and process messages

This initialization process is done in the main function of Activitythread, so after the main function is run, the UI thread message loop is started, and the message loop continuously reads and processes messages from the message queue, making the system work.

No4:

The processing of messages is divided into native layer and Java layer , two levels have their own message mechanism, native layer is based on pipeline and Epoll, while Java layer is a normal linked list.

"Android Source design mode"--Enjoy meta mode

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.