libev

Using boost::bind() across C code, will it work?

杀马特。学长 韩版系。学妹 提交于 2019-12-10 14:37:59
问题 Can I use boost::bind(mycallback, this, _1, _2) across C code? Update The short answer is no , boost bind does not return a function pointer, which can be called in C code, but a functor (C++ object with overloaded () operator) see answer below. 回答1: The best way to do what you want to do is to create a C callback that then calls the boost::function, which is stored in some sort of user memory with new. Example: void callFunction(void* data) { boost::function<void(void)> *func = (boost:

详解通过xtrabackup 工具备份mysql 5.7

假如想象 提交于 2019-12-09 15:52:14
由于之前服务器安装的xtrabackup比较老的版本,不支持mysql 5.7的热备,需要升级下版本或新服务器部署2.4.1版本。这里我们下载官网https://www.percona.com/downloads/XtraBackup/ 最新版2.4.4 工具,安装并备份mysql 5.7。 安装XtraBackup 这里不多做解释了,之前文章有介绍如何安装。 这里主要说下常见报错,比如我这里今天遇到两个: error: Failed dependencies: libev.so.4()(64bit) is needed by percona-xtrabackup-24-2.4.4-1.el6.x86_64 libnuma.so.1()(64bit) is needed by percona-xtrabackup-24-2.4.4-1.el6.x86_64 (1) libev.so.4()(64bit) is needed by percona-xtrabackup-24-2.4.4-1..el6.x86_64解决办法: rpm -ivh ftp://rpmfind.net/ linux /dag/redhat/el6/en/x86_64/dag/RPMS/libev-4.15-1.el6.rf.x86_64.rpm 安装上边rpm包解决 (2)libnuma.so.1()

Is libuv just a wrapper on libev on POSIX systems?

↘锁芯ラ 提交于 2019-12-05 13:19:50
I am really confused between libev and libuv. Is libuv just a wrapper on libev on POSIX systems? If not where does it differ? No longer, since libuv-v0.9 Here is the libuv github issue which tracked the removal of libev from libuv. The reasons for removal are, to quote from the above linked issue: In case any project watchers are wondering, libev served us well but: It only supports level-triggered I/O. On Linux, we want to use edge-triggered mode - it cuts down the number of syscalls by a substantial margin. libev's inner loop does a lot of things we don't really need. Gutting the inner loop

Libev, How to pass arguments to relevant callbacks

人走茶凉 提交于 2019-12-04 22:23:56
I'm trapped in a situation of argument passing in libev. Usually, libev receives packages in a function like *receive_callback* , that's OK, but in practice, we need to dispatch a relative *write_callback* to deal with specific jobs according to the received package. For example: S_RECV_MSG* pstRecvMsg = (S_RECV_MSG*) recv_buff; switch(pstRecvMsg->wMsgType) { case 1: ev_io_init(w, write_callback1, w->fd, EV_WRITE); break; case 2: ev_io_init(w, write_callback2, w->fd, EV_WRITE); break; case 3: // ....... } My question is, if the write_callbackX also has to read the specific content in the recv

后端的轮子(三)--- 缓存

 ̄綄美尐妖づ 提交于 2019-12-04 20:10:05
前言 前面花了一篇文章说数据库这个轮子,其实说得还很浅很浅的,真正的数据库比这复杂不少,今天我们继续轮子系列,今天说说缓存系统吧。 缓存是后端使用得最多的东西了,因为性能是后端开发一个重要的特征,所以缓存就应运而生了,而且现在缓存已经到了泛滥的程度了,我几乎没见过没有缓存的后端,一遇到性能问题,首先想到的不是看代码,而是加缓存,我也是醉了,好了,不扯这些,这些和今天的文章无关,今天我们来专门讲讲缓存吧。 缓存和KVDB 缓存和KVDB两个东西经常一起出现,两者在使用上没有明显的界限,当一个KVDB速度够快,性能够强劲,那么就可以当缓存来用了,我们使用Redis来做缓存,实际上就是把一个KVDB来当缓存用。但一般情况下,KVDB能提供更多的数据结构,所以象Redis这样的KVDB中有很多实用的数据结构,比如List啊,hashtable啊之类的,而且KVDB一般都提供持久化的存储,而像memcached这样的纯缓存一般不提供持久化存储功能,而且数据结构也比较简单,仅仅提供key和value都是字符串的形式。 现在KVDB的代表Redis性能已经越来越强劲了,虽然它是个单线程的服务,但目前基本上能用memcached的都可以用Redis代替,而且Redis因为支持更多的数据结构,所以扩展性更好。现在很多情况下所说的缓存,实际上都是指的是Redis缓存。 缓存的类型

Libev, How to pass arguments to relevant callbacks

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm trapped in a situation of argument passing in libev. Usually, libev receives packages in a function like *receive_callback* , that's OK, but in practice, we need to dispatch a relative *write_callback* to deal with specific jobs according to the received package. For example: S_RECV_MSG * pstRecvMsg = ( S_RECV_MSG *) recv_buff ; switch ( pstRecvMsg -> wMsgType ) { case 1 : ev_io_init ( w , write_callback1 , w -> fd , EV_WRITE ); break ; case 2 : ev_io_init ( w , write_callback2 , w -> fd , EV_WRITE ); break ; case 3 : // ......

Libev库学习

纵然是瞬间 提交于 2019-12-03 04:32:33
Libev库学习 https://www.cnblogs.com/wunaozai/p/3950249.html Libev库学习(1) https://www.cnblogs.com/wunaozai/p/3954131.html Libev库学习(2) https://www.cnblogs.com/wunaozai/p/3955156.html Libev库学习(3) https://www.cnblogs.com/wunaozai/p/3960494.html Zlib库的安装与使用 https://segmentfault.com/a/1190000006173864 01:概述和 ev_loop https://segmentfault.com/a/1190000006200077 02:watcher 基础 https://segmentfault.com/a/1190000006679929 03:常用 watcher 接口 https://www.cnblogs.com/gqtcgq/p/7247102.html Libev中的相对时间定时器 ev_timer https://www.cnblogs.com/gqtcgq/p/7247100.html Libev中的绝对时间定时器 ev_periodic https://www.cnblogs.com/gqtcgq

libev与libuv的区别

匿名 (未验证) 提交于 2019-12-03 00:15:02
libev与libuv的区别 https://www.cnblogs.com/charlesblc/p/6341280.html 参考: http://blog.csdn.net/w616589292/article/details/46475555 libuv libev epoll kqueue libev epoll kqueuq select livev libev accept(3) setnonblocking EAGAIN EWOULDBLOCK EINTER libuv libuv libuv libuv libuv EAGAIN EWOULDBLOCK libuv libev read(3) write(3) libuv 当接口可读时, libuv libuv free 而对写的处理则更显巧妙。 libuv libuv libuv libuv libuv libev void *data libev libuv libev libuv getaddrinfo(3) libev libuv libev IOCP libuv IOCP 参考: http://blog.csdn.net/w616589292/article/details/46475555 libuv libev epoll kqueue libev epoll kqueuq select livev

Why use do { } while (0) in macro definition? [duplicate]

亡梦爱人 提交于 2019-12-02 18:45:28
Possible Duplicate: Why are there sometimes meaningless do/while and if/else statements in C/C++ macros? I met code like below: #define ev_io_init(ev,cb,fd,events) \ do { \ ev_init ((ev), (cb)); \ ev_io_set ((ev),(fd),(events)); \ } while (0) I want to know why the author use do { } while (0) here. Is there any difference with this? #define ev_io_init(ev,cb,fd,events) { \ ev_init ((ev), (cb)); \ ev_io_set ((ev),(fd),(events)); \ } BTW: the code is from libev, ev_local.h Consider if( something ) function1(); else function2(); If function1() is actually a macro, just using { } requires you to

core_framework —— 基于libev的轻量级lua网络开发框架

旧街凉风 提交于 2019-12-02 18:03:03
大道至简, 返璞归真. 前言 在发表这篇博文的前夕, 还有一些小伙伴在提问一些以下相关的问题: 性能怎么样? 是否容易上手? 开发目标在哪? 如何反馈问题? 对比行业内的lua开源项目有何优势? 等等, 以上问题会在本文中一一介绍. CF的起因 首先来聊聊情怀这个东西! 相信每一个行业内的从业者都或多或少有过一个梦, 这个梦叫做: "我到时候要开发一个XXX"!其实作者当初也是一样. 每当半夜(凌晨)在加班、看文档、调试的时候, 总会搜索到一些几年前或十几年前的框架或入门demo。例如: tinyhttp , 链接的源码是一些同学fork的镜像站。 每次看到这些内容或多或少都会激起心中那一丝丝快熄灭的热情, 也许这就是最后对技术的渴望? 就是在动手创建项目之前还反复问过自己是否要做? 能坚持下去么?也许被喷都是一种奢望? 在心里一一回答了这些问题后, 在2018年末创建了 本项目 . 说句实话! 一个网络开发框架最难的不是实现某个功能, 而是从零开始一步一步添砖加瓦的造轮子! 作为一个网络开发框架, 最重要的两个功能肯定是需要的! 定时器库、事件驱动库. 如何抉择?选项有2个: libev / libuv . libev 成熟稳定、轻量级、unix like支持、容易嵌入; libuv 比libev更加优秀,增加了许多功能(线程池、信号、同步、锁等等),封装更加完善,