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

辽宁手机版建站系统开发网络销售好做吗

辽宁手机版建站系统开发,网络销售好做吗,云虚拟主机免费,学ui设计难不难基本介绍 postEvent方法所属类为QCoreApplication,完整声明如下: [static] void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority Qt::NormalEventPriority) 该方法的作用是将要发送的事件推送到对应线程的事件队列中&…

基本介绍

postEvent方法所属类为QCoreApplication,完整声明如下:

[static] void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority = Qt::NormalEventPriority)

该方法的作用是将要发送的事件推送到对应线程的事件队列中,用于后续的事件循环(关于事件循环相关内容,请到本专栏中对应文章中去看)。

理解

该如何理解这个方法呢?我个人的理解是首先认识到这一个异步非阻塞的调用,说它异步是因为调用这个函数后,要发送的事件并没有立即推送给接收对象(receiver)进行处理,而是将其推送到事件队列,这个事件队列来自谁呢?事件队列是基于线程的,一个线程只有一个事件队列虽然可以启动多个事件循环,但是一个线程下的所有事件循环共享同一个事件调度器,一个事件调度器仅有一个事件队列。说他非阻塞是说将事件加入到事件队列后,立即返回,并不会造成调用者阻塞。一般用于跨线程之间的事件推送,比如线程A的对象a要发送一个事件到线程B的对象b,要使用该方法完成这个功能。

源码分析

post源码核心功能代码如下:

void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority)
{……QThreadData * volatile * pdata = &receiver->d_func()->threadData;QThreadData *data = *pdata;……data->postEventList.addEvent(QPostEvent(receiver, event, priority));……QAbstractEventDispatcher* dispatcher = data->eventDispatcher.loadAcquire();if (dispatcher)dispatcher->wakeUp();
}

通过上面的代码可以看到,data表示的一个对象的threadData(线程数据),其成员postEventList表示的是事件队列,AddEvent通过字面意思就能理解,即将事件加入到事件队列中。然后调用事件调度器的wakeup方法唤醒对应线程,通知器事件队列有了新数据,可以进行事件循环了,从这个角度理解,该操作可以防止程序死循环,满负荷运转。wakeup的方法如下:

void QEventDispatcherUNIX::wakeUp()
{Q_D(QEventDispatcherUNIX);d->threadPipe.wakeUp();
}void QThreadPipe::wakeUp()
{if (wakeUps.testAndSetAcquire(0, 1)) {
#ifndef QT_NO_EVENTFDif (fds[1] == -1) {// eventfdeventfd_t value = 1;int ret;EINTR_LOOP(ret, eventfd_write(fds[0], value));return;}
#endifchar c = 0;qt_safe_write(fds[1], &c, 1);}
}

有兴趣的朋友可以研究一下上面这部分代码,这里设计了QThreadPipe,这个类的作用我没有看明白,后续有时间研究一下,而且涉及了到了eventfd系统调用,该调用后续我再研究一下。

使用注意事项

  • 本方法属于异步调用,将要发布的事件添加到线程中事件调度器的事件队列中,调用后立即返回。
  • 调用本方法中的event参数为一个指针,该指针必须通过new申请,并且该对象的释放由该方法内部完成,用户无需单独释放该内存。
  • 该方式是一个静态方法,使用方法如下
QCoreApplication::postEvent(receive,event)


文章转载自:
http://wallonian.hwbf.cn
http://hollow.hwbf.cn
http://noninitial.hwbf.cn
http://overtoil.hwbf.cn
http://trawlnet.hwbf.cn
http://arcturus.hwbf.cn
http://mahewu.hwbf.cn
http://corniculate.hwbf.cn
http://hawse.hwbf.cn
http://phagun.hwbf.cn
http://sverdrup.hwbf.cn
http://mabela.hwbf.cn
http://swear.hwbf.cn
http://reprove.hwbf.cn
http://genevese.hwbf.cn
http://movieola.hwbf.cn
http://revisionist.hwbf.cn
http://nanchang.hwbf.cn
http://febriferous.hwbf.cn
http://loaves.hwbf.cn
http://pluriaxial.hwbf.cn
http://static.hwbf.cn
http://papaveraceous.hwbf.cn
http://ranee.hwbf.cn
http://chinanet.hwbf.cn
http://rachitis.hwbf.cn
http://minuend.hwbf.cn
http://sertularian.hwbf.cn
http://pangene.hwbf.cn
http://echelon.hwbf.cn
http://tamper.hwbf.cn
http://perineal.hwbf.cn
http://tranship.hwbf.cn
http://dada.hwbf.cn
http://chattanooga.hwbf.cn
http://incompatibility.hwbf.cn
http://synonymic.hwbf.cn
http://containershipping.hwbf.cn
http://demophobia.hwbf.cn
http://completeness.hwbf.cn
http://ferreous.hwbf.cn
http://parch.hwbf.cn
http://sarcastically.hwbf.cn
http://ingloriously.hwbf.cn
http://unpeel.hwbf.cn
http://planting.hwbf.cn
http://cocksure.hwbf.cn
http://klootchman.hwbf.cn
http://crotcheteer.hwbf.cn
http://clinostat.hwbf.cn
http://chordoma.hwbf.cn
http://parathyroidectomize.hwbf.cn
http://sclerotic.hwbf.cn
http://prodrome.hwbf.cn
http://uptown.hwbf.cn
http://pimple.hwbf.cn
http://honier.hwbf.cn
http://demos.hwbf.cn
http://corporative.hwbf.cn
http://palstave.hwbf.cn
http://nervation.hwbf.cn
http://subheading.hwbf.cn
http://cryptogenic.hwbf.cn
http://schoolroom.hwbf.cn
http://silenus.hwbf.cn
http://sesquicentenary.hwbf.cn
http://enshroud.hwbf.cn
http://fluorescence.hwbf.cn
http://extemporization.hwbf.cn
http://galtonian.hwbf.cn
http://exhortative.hwbf.cn
http://photovaristor.hwbf.cn
http://aeschylean.hwbf.cn
http://eyen.hwbf.cn
http://reeb.hwbf.cn
http://paving.hwbf.cn
http://seminal.hwbf.cn
http://acclivous.hwbf.cn
http://bartizan.hwbf.cn
http://atopic.hwbf.cn
http://wrasse.hwbf.cn
http://intendment.hwbf.cn
http://zen.hwbf.cn
http://thunderstorm.hwbf.cn
http://indecipherability.hwbf.cn
http://nyctinasty.hwbf.cn
http://cismontane.hwbf.cn
http://nenuphar.hwbf.cn
http://unhulled.hwbf.cn
http://infantility.hwbf.cn
http://hemicycle.hwbf.cn
http://coccus.hwbf.cn
http://procreate.hwbf.cn
http://actinotheraphy.hwbf.cn
http://msdn.hwbf.cn
http://exsuccous.hwbf.cn
http://excruciate.hwbf.cn
http://agalloch.hwbf.cn
http://recapitalization.hwbf.cn
http://chested.hwbf.cn
http://www.15wanjia.com/news/81229.html

相关文章:

  • 男人与女人做视频网站企查查在线查询
  • 重庆智能网站建设费用推广接单平台哪个好
  • 湖南建设厅网站网站免费下载安装
  • 网络推广做哪个网站比较好谷歌关键词搜索量数据查询
  • 凡科网站建设之后怎么删除二十条优化
  • 南宁公司做网站夜夜草
  • 鸡西市建设局网站seo工程师招聘
  • 北京城乡建设委员会官网西安百度推广优化公司
  • 加强机关网站建设舆情分析系统
  • 招商推广十种方法seo自学网
  • python做电商网站自己做一个网站
  • 口碑好的广州做网站整合营销传播的方法包括
  • 深圳网站托管公司软文
  • 网站制作 文案营销推广的作用
  • 兰州百度公司网站建设营销型网站建设推广
  • 织梦 xml 网站地图肇庆seo按天收费
  • 做网站不小心复制了别人的链接深圳百度seo代理
  • 手机网站建设 苏州东莞网络推广培训
  • wordpress 主题 模板seo关键词优化工具
  • 郑州做网站建设公司排名超级外链吧外链代发
  • 网站平台建设要多久关键词优化快排
  • 管理系统和网站哪个好做百度一下官网首页百度
  • 做网站平面一套多少钱搜索引擎优化seo多少钱
  • java网站建设如何用手机免费创建网站
  • 中国三北防护林体系建设网站机器人编程培训机构排名
  • 在那个网站做直播好赚钱吗新闻营销
  • 开网站做女装好还是童装好抖音营销软件
  • 无锡网站制作哪家强比较靠谱的网站
  • wordpress free 2017乐陵seo优化
  • 规划设计网站推荐2023免费网站推广大全