libevent for qt网络模块
libevent for qt网络模块,直接替换qt的select模型,支持epoll,select,pool.使用非常简单,无需修改以前的代码结构
最近在开发im服务器,需要大并发链接。QT默认的是使用select模型的,这种轮询方式非常慢。在高并发连接,我们需要epoll才能发挥linux服务器的性能.而且使用简单,整个服务端代码架构无需修改,设置QT的分发事件就可以使用了,只要在main里面添加 :
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
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文件添加
Vim
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
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
}
|
可以直接跨平台了使用了
附上qt libevent源码下载地址:qt_libevent.zip
http://love.junzimu.com/archives/2657
libevent for qt网络模块的更多相关文章
- libevent for qt的讨论
一直对Qt官方的QtNetwork模块抱有遗憾,Qt自带的网络模块用的是select模型,无法支持高并发的服务器开发.最近在网上看到有个libevent for qt的东西,它直接替换了Qt的sele ...
- Qt 网络模块如何使用?
1.网络模块介绍 类名 说明 中文 QAbstractNetworkCache The interface for cache implementations 缓存实现的接口 QNetworkCach ...
- Qt网络模块如何使用(表格)
1.网络模块介绍 类名 说明 中文 QAbstractNetworkCache The interface for cache implementations 缓存实现的接口 QNetworkCach ...
- GeoServer-REST应用:基于Qt网络编程一键同步发布空间数据和样式至GeoServer
@ 目录 简介 配置 步骤 1.引入Qt网络模块 2.创建网络管理.网络响应.网络请求 3.创建工作空间 4.创建数据存储并上传数据 5.上传样式文件 6.图层发布 6.图 ...
- Primecoin在windows上的部署和启动服务
Primecoin在windows上的部署和启动服务: 一.从官方获得Primecoin的windows版安装包: 二.一路像安装客户端一样的安装: 三.安装成功后它会自动弹出客户端运行,同步数据, ...
- bitcoind
Bitcoin Core Daemon version v0.15.1.0-g7b57bc998f Usage: bitcoind [options] Start Bitcoin Core Daemo ...
- Qt中加载Libevent静态库(通过reimp和rs两条语句将lib转为a)
文章来源:http://blog.sina.com.cn/s/blog_731bf4c90102wnpr.html 本文仅是个人经验总结,若有错误欢迎指教! 最近要做一个跨平台的项目,同时也涉及到网络 ...
- Qt 工程 pro文件
工作中,感觉pro文件的有些内容真不太懂,现系统性的学习一下.于此备录,分享共勉. 为了更好的理解,先创建一个简单的工程作为实践. [1]创建一个pro文件 1.1 新建proDemo工程.步骤如下: ...
- Qt之Threads和QObjects
简述 QThread继承自QObject,它发射信号(signals)以表明线程执行开始或结束,并提供了一些槽函数(slots). 更有趣的是,QObjects可以在多线程中使用,发射信号以在其它线程 ...
随机推荐
- LeetCode_Subsets
Given a set of distinct integers, S, return all possible subsets. Note: Elements in a subset must be ...
- AnimateWindow
WINDOWS提供了一个很有意思的函数:AnimateWindow.之前我想实现像MSN,QQ这些收到邮件的时候动画方式,从地下升上来的显示一个窗口,感觉很麻烦,自己去写代码,效果很不理想,今天无意中 ...
- Powershell环境变量
Powershell环境变量 9 12月, 2011 在 Powershell tagged 变量by Mooser Lee 本文索引 [隐藏] 1读取特殊的环境变量 2查找环境变量 3创建新的环境 ...
- 解决kibana 4 关于响应时间的问题
"message" => " 10.252.142.174 [12/Sep/2016:16:43:47 +0800] \"GET /resources/j ...
- Wiggle Sort 解答
Question Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= num ...
- Linux web性能优化
1,
- git错误:fatal: Not a git repository (or any of the parent directories): .git
git错误:fatal: Not a git repository (or any of the parent directories): .git 我用git add file添加文件时出现这样错误 ...
- MySql命令——函数
1.拼接字段——Concata() 把多个串连接起来形成一个较长的串. select concat(value,'(',id,')') from test; 2.去掉空格 RTrim() 去掉右边的空 ...
- jquery返回顶部
// 返回顶部 var fixed_totop = $('.back_top').on('click',function(){ $('html, body').animate({scrollTop: ...
- Android布局自定义Shap圆形ImageView,可以单独设置背景与图片
一.图片预览: 一.实现功能: 需求要实现布局中为圆形图片,图片背景与图标分开且合并到一个ImageView. 二.具体实现: XML中布局中定义ImageView, ...