1. 了解计算机程序
程序分类
script
continuous running
我们开发的交易系统数据连续运行型
事件驱动和时间驱动
2. 时间驱动
from time import sleep
def demo():
print "run demo every 1 second"
while 1:
demo()
sleep(1.0)
缺点: 延迟
3. 事件驱动
onTick()
绘图
表格更新
运算、下单
运算、下单
风控
4. 事件驱动引擎
4.1 初始化
__queue 保存事件的队列
__active 开关
__thread 线程
__timer 计时器
__handlers 处理函数字典
4.2 注册事件处理函数
1. type_
2. handler
4.3 触发
4.4 事件处理线程的连续运行
__thread中连续运行工作的函数为__run __process
4.5 计时器
4.6 启动、停止