Home  >  Article  >  Database  >  阅读Redis源码(三) -- redis通信协议与事件驱动

阅读Redis源码(三) -- redis通信协议与事件驱动

WBOY
WBOYOriginal
2016-06-07 16:37:061180browse

在redis中,关于事件驱动框架的代码集中在ae.h/ae.c中.作者也在头部设置了介绍:a simple event-driven programming library. 这个框架其实很简单,核心就是一个消息队列,同时只有一个线程负责对其进行处理,这里面的调度思想,还是简单的优先级队列,文件操作优先

在redis中,关于事件驱动框架的代码集中在ae.h/ae.c中.作者也在头部设置了介绍:a simple event-driven programming library. 这个框架其实很简单,核心就是一个消息 队列,同时只有一个线程负责对其进行处理,这里面的调度思想,还是简单的优先级队列,文件操作优先级永远高于时间操作.而且任务之间并不会进行抢占. 具体执行过程,可以参照如下干特图: ``` time -------... 0 ,那么说明目前没有任何时间事件到达 nearest_te_remaind_ms = te.when - now_in_ms() if nearest_te_remaind_ms >
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn