5. Dispatcher(任务分发器)会通过Handler来提交任务,然后交由Dispatcher的performSubmit方法来执行
void performSubmit(Action action, boolean dismissFailed) {
if (pausedTags.contains(action.getTag())) {
pausedActions.put(action.getTarget(), action);
...
return;
}
//查看是否有对应url的缓存的hunter
//BitmapHunter的简介请看文章开始的介绍
BitmapHunter hunter = hunterMap.get(action.getKey());
if (hunter != null) {
hunter.attach(action);
return;
}
if (service.isShutdown()) {
...
return;
}
hunter = forRequest(action.getPicasso(), this, cache, stats, action);
//提交任务到线程池
hunter.future = service.submit(hunter);
//将runnable缓存在map集合中
hunterMap.put(action.getKey(), hunter);
if (dismissFailed) {
failedActions.remove(action.getTarget());
}
...
} |