Flow chart analysis of volley frame

Source: Internet
Author: User

This article mainly focuses on the principle of volley framework operation. The main use of the flow chart to describe, simple analysis of the entire process of the process, please refer to the source code or see my previous article at the end of the link added.

First, the preparation of volley

Generates a requestqueue queue.

Second, users add request

Third, blocking threads

(1) Cache queue processor

(2) Network request processor

Four, data distribution device

As the network response processor

V. Summary

1. When a requestqueue is successfully applied, it will open a cachedispatcher (Cache scheduler) and 4 (default) Networkdispatcher (Network request scheduler);

2. The Cachedispatcher Cache Scheduler is the first layer of buffering that blocks the request from the cache sequence Mcachequeue after it has started working:

A. For a request that has been canceled, mark it as skipped and end the request directly
B. New or expired requests, directly dropped into mnetworkqueue to be processed by N networkdispatcher
C. The cached information (network response) has not expired and is submitted to the request's parsenetworkresponse for resolution to determine whether the answer was successful. The request and reply are then referred to the delivery distributor for processing, and if the cache needs to be updated, the request is also put into Mnetworkqueue

3. After the user requests the request add to Requestqueue:

A. For requests that do not need to be cached (additional settings are required, the cache is required by default), the direct throw-in Mnetworkqueue is processed by n Networkdispatcher;
B. For a new request to be cached, add the Mcachequeue to the Cachedispatcher processing
c. Need to cache, but the cache list already has the same URL of the request, placed in the mwaitingqueue to do temporary snow, wait until the request has been completed, and then re-added to the mcachequeue;

4. The network request Scheduler Networkdispatcher as the network request real occurrence place, the message to the basicnetwork carries on the processing, similarly, the request and the result is referred to the delivery distribution person to handle;

5. The delivery distributor is actually the last layer on the network request processing, and the request has already resolved the network response before the delivery requests are processed, and the answer has been successfully set. The delivery is then treated differently depending on the response received from the request:

A. If the answer is successful, the Deliverresponse method is triggered, which will trigger the developer to set the request for listener
B. If the answer fails, the Delivererror method is triggered, which will eventually trigger the developer to set the request for Errorlistener

after processing, the life cycle of a request is over, and delivery calls the request's finish operation to remove it from the Mrequestqueue, and at the same time, if a request for the same URL exists in the waiting list, The remaining level requests are all dropped into mcachequeue to be processed by Cachedispatcher.

Borrowed a summary of the blog (http://blog.csdn.net/airk000/article/details/39003587)


Other great article articles

 Android Learning Note (38) using ProgressDialog to create a skin feed dialog box
Large Web site architecture design-SOLR
Android Learning Note (39) Message tip Use TOAST to hint information lightly
Android Learning Note (32) grid view (GridView) and graphics switcher (Imageswi ...
Android Learning Note (31) Expandable List Component (Expandablelistview)
more about Android development articles

Flow chart analysis of volley frame

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.