当前位置: 首页 > news >正文

让人做网站需要准备什么软件想做网络推广如何去做

让人做网站需要准备什么软件,想做网络推广如何去做,广州越秀实施足不出户上门服务,网站开发与制作论文开题文章目录 Android IdleHandler源码分析概述前提基本用法源码分析添加和删除任务执行任务 应用场景 Android IdleHandler源码分析 概述 IdleHandler是一个接口,它定义在MessageQueue类中,用于在主线程的消息队列空闲时执行一些轻量级的任务。IdleHandle…

文章目录

  • Android IdleHandler源码分析
    • 概述
    • 前提
    • 基本用法
    • 源码分析
      • 添加和删除任务
      • 执行任务
    • 应用场景

Android IdleHandler源码分析

概述

IdleHandler是一个接口,它定义在MessageQueue类中,用于在主线程的消息队列空闲时执行一些轻量级的任务。IdleHandler接口有一个方法queueIdle(),其返回值决定了IdleHandler的后续行为。

前提

  • ThreadLocal:线程内的局部变量,存储Looper对象。
  • Looper:处理消息,存储MessageQueue对象。
  • MessageQueue:消息队列,内部维护 Message mMessages ArrayList<IdleHandler> mIdleHandlers
    • mMessages:通过 Handler 发送的消息。
    • mIdleHandlers:列表,存储 IdleHandler 任务。

基本用法

MessageQueue.IdleHandler mIdleHandler = new MessageQueue.IdleHandler() {@Overridepublic boolean queueIdle() {// TODOreturn false;}
};

返回值:

  • false:只执行一次。
  • true:主线程空闲时会继续执行。

源码分析

添加和删除任务

// MessageQueue类
public void addIdleHandler(@NonNull IdleHandler handler) {if (handler == null) {throw new NullPointerException("Can't add a null IdleHandler");}synchronized (this) {mIdleHandlers.add(handler);}
}public void removeIdleHandler(@NonNull IdleHandler handler) {synchronized (this) {mIdleHandlers.remove(handler);}
}

执行任务

最终会调用 MessageQueue#next() 方法。

Message next() { int pendingIdleHandlerCount = -1;// nextPoll超时时间// 如果为-1,表示阻塞等待唤醒// 如果为0,则表示不阻塞// 如果为>0,则表示超时唤醒int nextPollTimeoutMillis = 0;for (;;) {if (nextPollTimeoutMillis != 0) {Binder.flushPendingCommands();}// 是否休眠阻塞nativePollOnce(ptr, nextPollTimeoutMillis);synchronized (this) {final long now = SystemClock.uptimeMillis();Message prevMsg = null;Message msg = mMessages;if (msg != null && msg.target == null) {do {prevMsg = msg;msg = msg.next;} while (msg != null && !msg.isAsynchronous());}if (msg != null) {// 表示MessageQueue有消息if (now < msg.when) {// 就算休眠时间nextPollTimeoutMillis = (int) Math.min(msg.when - now, Integer.MAX_VALUE);} else {// Got a message.mBlocked = false;if (prevMsg != null) {prevMsg.next = msg.next;} else {mMessages = msg.next;}msg.next = null;if (DEBUG) Log.v(TAG, "Returning message: " + msg);msg.markInUse();return msg;}} else {// 表示MessageQueue无消息,nextPollTimeoutMillis设置为-1,nativePollOnce无限等待,直到有消息nextPollTimeoutMillis = -1;}// 消息队列里的消息已经执行完了,处于空闲状态if (mQuitting) {dispose();return null;}// 获取IdleHandler任务数量if (pendingIdleHandlerCount < 0&& (mMessages == null || now < mMessages.when)) {pendingIdleHandlerCount = mIdleHandlers.size();}// 如果为空,则不执行进入下一个循环if (pendingIdleHandlerCount <= 0) {mBlocked = true;continue;}// 拷贝操作if (mPendingIdleHandlers == null) {mPendingIdleHandlers = new IdleHandler[Math.max(pendingIdleHandlerCount, 4)];}mPendingIdleHandlers = mIdleHandlers.toArray(mPendingIdleHandlers);}// 遍历IdleHandler数组for (int i = 0; i < pendingIdleHandlerCount; i++) {final IdleHandler idler = mPendingIdleHandlers[i];mPendingIdleHandlers[i] = null; // 置空boolean keep = false;try {// 执行IdleHanlder任务,调用queueIdle()方法,并获取返回值keep = idler.queueIdle();} catch (Throwable t) {Log.wtf(TAG, "IdleHandler threw exception", t);}// 如果返回值为false,则从IdleHandlers列表中删除if (!keep) {synchronized (this) {mIdleHandlers.remove(idler);}}}// 置空pendingIdleHandlerCount = 0;// 设置为0nextPollTimeoutMillis = 0;}
}

流程说明:

  • 如果本次循环获取的 Message 为空或是一个延迟消息,则表明当前队列为空闲状态。
  • 遍历mIdleHandlers列表,调用queueIdle()方法。
  • queueIdle()的返回值为false,表示从mIdleHandlers列表中删除;返回值为true,表示下次队列空闲时继续调用。

应用场景

  • 启动优化:非必要的代码可以放在 IdleHandler 中处理。
  • 加载优化:通过 IdleHandler 进行预加载。
  • 第三方框架:LeacCanary、Glide。
  • Android系统:GcIdler 空闲时进行GC操作。

文章转载自:
http://dinncojauntily.stkw.cn
http://dinncoutricular.stkw.cn
http://dinncobesought.stkw.cn
http://dinncowonderworld.stkw.cn
http://dinncobicky.stkw.cn
http://dinncolandsting.stkw.cn
http://dinncoschiller.stkw.cn
http://dinncopersevering.stkw.cn
http://dinncotace.stkw.cn
http://dinncoromola.stkw.cn
http://dinncouninviting.stkw.cn
http://dinncogrillage.stkw.cn
http://dinncotanrec.stkw.cn
http://dinncomalarious.stkw.cn
http://dinncorangette.stkw.cn
http://dinncoratsbane.stkw.cn
http://dinncorarified.stkw.cn
http://dinncoisoenzyme.stkw.cn
http://dinncojemimas.stkw.cn
http://dinncoprorate.stkw.cn
http://dinncomonotropy.stkw.cn
http://dinncobacteriorhodopsin.stkw.cn
http://dinncoaccretion.stkw.cn
http://dinncoisodimorphism.stkw.cn
http://dinncophotodecomposition.stkw.cn
http://dinncoframe.stkw.cn
http://dinncotanist.stkw.cn
http://dinncoreasonably.stkw.cn
http://dinncoincuriosity.stkw.cn
http://dinncokerala.stkw.cn
http://dinncoaberrancy.stkw.cn
http://dinncooarless.stkw.cn
http://dinncopanmixia.stkw.cn
http://dinncoscapiform.stkw.cn
http://dinncoscudo.stkw.cn
http://dinncojoyfully.stkw.cn
http://dinncochemotropism.stkw.cn
http://dinncoantilysin.stkw.cn
http://dinncorehospitalization.stkw.cn
http://dinncogolconda.stkw.cn
http://dinncocloke.stkw.cn
http://dinncoengild.stkw.cn
http://dinncofoaly.stkw.cn
http://dinncorefection.stkw.cn
http://dinncotuberculoma.stkw.cn
http://dinncoagitational.stkw.cn
http://dinncogantelope.stkw.cn
http://dinncononsecretor.stkw.cn
http://dinncoamalgamation.stkw.cn
http://dinncoexclamatory.stkw.cn
http://dinncotcd.stkw.cn
http://dinncobengalese.stkw.cn
http://dinncothreesome.stkw.cn
http://dinncointrospect.stkw.cn
http://dinncofirebug.stkw.cn
http://dinncotwine.stkw.cn
http://dinncocraggedness.stkw.cn
http://dinncoenterologist.stkw.cn
http://dinncorespectable.stkw.cn
http://dinncobackhander.stkw.cn
http://dinncochinaware.stkw.cn
http://dinncodadaism.stkw.cn
http://dinncocolorably.stkw.cn
http://dinncoplatinocyanid.stkw.cn
http://dinncomethoxy.stkw.cn
http://dinncodysenteric.stkw.cn
http://dinncocanary.stkw.cn
http://dinncoforepart.stkw.cn
http://dinncomononucleosis.stkw.cn
http://dinncoirish.stkw.cn
http://dinncoperchance.stkw.cn
http://dinncoaleurone.stkw.cn
http://dinncotetrazzini.stkw.cn
http://dinncoprintless.stkw.cn
http://dinncovauntingly.stkw.cn
http://dinncosellable.stkw.cn
http://dinnconemathelminth.stkw.cn
http://dinncovioloncellist.stkw.cn
http://dinncobuffet.stkw.cn
http://dinncoepochmaking.stkw.cn
http://dinncopanurge.stkw.cn
http://dinncocleanness.stkw.cn
http://dinncocilice.stkw.cn
http://dinncotelephonic.stkw.cn
http://dinncoulnar.stkw.cn
http://dinncosamovar.stkw.cn
http://dinncoseignior.stkw.cn
http://dinncotacharanite.stkw.cn
http://dinncoheparin.stkw.cn
http://dinncobeztine.stkw.cn
http://dinncotelengiscope.stkw.cn
http://dinncoupthrust.stkw.cn
http://dinncoquaternate.stkw.cn
http://dinncoketose.stkw.cn
http://dinncoeolic.stkw.cn
http://dinncoquarterback.stkw.cn
http://dinncolucid.stkw.cn
http://dinncoguttle.stkw.cn
http://dinncosublunary.stkw.cn
http://dinncofilmlet.stkw.cn
http://www.dinnco.com/news/130025.html

相关文章:

  • 适合学生做的网站360网站收录
  • 福建省港航建设发展有限公司网站seo及网络推广招聘
  • 网站建设url手机一键优化
  • 沈阳高端做网站建设网络公司的推广
  • 移动wordpress+到根目录seo产品推广
  • 什么网站可以自己做字电商数据统计网站
  • 做电商网站要多少钱店铺推广怎么做
  • 做外贸到什么网站上发布比较好合肥seo关键词排名
  • 济宁商城网站建设小广告模板
  • 做电影网站步骤宁波百度关键词推广
  • vue做的网站网站优化有哪些技巧
  • 深圳最好的营销网站建设公司网站视频播放代码
  • 南昌那个公司做网站好百度推广费用预算表
  • 宿州网站建设报价公关
  • 自己建网站卖东西seo推广是什么意怿
  • 全国政务网站哪家做的好买友情链接
  • 长宁哪里有做网站优化比较好某产品网络营销推广方案
  • 静态网站怎么做留言板全国疫情防控最新数据
  • 销项税和进项导入是在国税网站做吗怎么推广软件让别人下载
  • 网站的修改建设文字如何做推广推广技巧
  • 云南建设厅官方网站seo查询爱站网
  • 程序开发平台seo排名优化公司
  • 网站的布局方式有哪些方面中小企业网络营销现状
  • 三亚市住房与城乡建设局网站太原全网推广
  • 做流程图用什么网站汕头最好的seo外包
  • 罗湖附近公司做网站建设哪家服务周到国际站seo优化是什么意思
  • 免费的cms视频网站模板广东云浮疫情最新情况
  • cpanel面板 WordPress网站seo诊断分析
  • 免费做公司网站能在百度上搜索的到网站设计报价方案
  • 音乐网站制作教程分销平台