Qt事件循环、IO、基于libev的Qt事件循环

http://user.qzone.qq.com/892054726/blog/1471508263

 基于libev的Qt事件循环可以提高网络等模块的性能。地址如下:
https://github.com/sjinks/qt_eventdispatcher_libev
libev的手册: http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod
 

eventdispatcher_libev 使用方法

Usage (Qt 5)

Simply include the header file and instantiate the dispatcher in main() before creating the Qt application object.

# include  "eventdispatcher_libev.h"
 
int  main( int argc,  char** argv)

QCoreApplication::setEventDispatcher( new EventDispatcherLibEv); 
QCoreApplication  app(argc, argv); 
// ...
 
  return app. exec();
}

And add these lines to the .pro file:

unix { CONFIG += link_pkgconfig PKGCONFIG += eventdispatcher_libev}
else:win32 

include(/path/to/qt_eventdispatcher_libev/lib/eventdispatcher_libev.pri)
}

or

HEADERS += /path/to/eventdispatcher_libev.h
LIBS += -L/path/to/library -leventdispatcher_libev
 

Qt 5 allows to specify a custom event dispatcher for the thread:

QThread* thr =  new QThread; 
thr-> setEventDispatcher ( new  EventDispatcherLibEv);  

 Qt自带的事件循环
Qt使用QSocketNotifier监听文件。 http://blog.csdn.net/qustdjx/article/details/7649508

Qt事件循环和IO设计的介绍https://www.qtdeveloperdays.com/2013/sites/default/files/presentation_pdf/Qt_Event_Loop.pdf ;














 







 

 

 

 















 

































 

 

 



 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
最近在开发im服务器 需要大并发链接 QT默认的是使用select模型的 这种轮询方式非常慢 在高并发连接 我们需要epoll才能发挥linux服务器的性能 而且使用简单 整个服务端代码架构无需修改 直接可以使用 只要在 main文件添加: int main int argc char argv[] { #ifdef Q OS LINUX QCoreApplication::setEventDispatcher new EventDispatcherLibEvent ; qInstallMessageHandler customMessageHandler ; #endif QCoreApplication a argc argv ; auto ser new ConfigServer; ser >startServer ; return a exec ; } 在 pro文件添加 linux{ LIBS + levent core SOURCES + common eventdispatcher libevent eventdispatcher libevent cpp common eventdispatcher libevent eventdispatcher libevent config cpp common eventdispatcher libevent eventdispatcher libevent p cpp common eventdispatcher libevent socknot p cpp common eventdispatcher libevent tco eventfd cpp common eventdispatcher libevent tco pipe cpp common eventdispatcher libevent tco cpp common eventdispatcher libevent timers p cpp HEADERS + common eventdispatcher libevent common h common eventdispatcher libevent eventdispatcher libevent h common eventdispatcher libevent eventdispatcher libevent config h common eventdispatcher libevent eventdispatcher libevent config p h common eventdispatcher libevent eventdispatcher libevent p h common eventdispatcher libevent libevent2 emul h common eventdispatcher libevent qt4compat h common eventdispatcher libevent tco h common eventdispatcher libevent wsainit h } 可以直接跨平台了使用了 csdn博客:http: blog csdn net rushroom">最近在开发im服务器 需要大并发链接 QT默认的是使用select模型的 这种轮询方式非常慢 在高并发连接 我们需要epoll才能发挥linux服务器的性能 而且使用简单 整个服务端代码架构无需修改 直接可以使用 只要在 main文件添加: [更多]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值