volley总结

定义:是一个异步网络请求框架和图片加载框架缓存

做用:适合数据量小,通讯频繁的网络操做网络

优势:一、扩展性强,大多基于接口设计并发

          二、自动调度网络框架

          三、高并发网络链接异步

整体框架ide

volley网络请求过程当请求被添加到请求队列后,volley经过两种调度线程()不断从请求队列中取出请求,根据是否已缓存调用Cache或Network这两类数据获取接口之一,从缓存中或网络上取得数据。而后交给response delivery去作结果分发及回调处理。高并发

volley请求流程图post

volley主要类关系图ui

 RequestQueue:A request dispatch queue with a thread pool of dispatchers.Calling {@link  #add(Request)} will enqueue the given Request for dispatch, resolving from either cache or network on a worker thread, and then delivering a parsed response on the main thread.this

RequestQueue 中维护了两个基于优先级的 Request 队列,缓存请求队列和网络请求队列。

CacheDispatcher:Provides a thread for performing cache triage on a queue of requests.Requests added to the specified cache queue are resolved from cache.Any deliverable response is posted back to the caller via a{@link  ResponseDelivery}.  Cache misses and responses that require refresh are enqueued on the specified network queue for processing by a { @link  NetworkDispatcher}.

NetworkDispatcher:Provides a thread for performing network dispatch from a queue of requests.Requests added to the specified queue are processed from the network via a specified {@link  Network} interface. Responses are committed to cache, if eligible, using a specified {@link  Cache} interface. Valid responses and errors are posted back to the caller via a {@link ResponseDelivery}.

Request<T>:Base class for all network requests.@param <T> The type of parsed response this request expects.

ExecutorDelivery:Delivers responses and errors.

DiskBasedCache:Cache implementation that caches files directly onto the hard disk in the specified directory. The default disk usage size is 5MB, but is configurable.

相关文章
相关标签/搜索