Skip to content

Commit

Permalink
修改EventEngine的启动函数,允许不启动Timer
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxy123 committed Jan 4, 2017
1 parent 5ef87e7 commit ac190f5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
22 changes: 15 additions & 7 deletions vn.event/eventEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,20 @@ def __onTimer(self):
self.put(event)

#----------------------------------------------------------------------
def start(self):
"""引擎启动"""
def start(self, timer=True):
"""
引擎启动
timer:是否要启动计时器
"""
# 将引擎设为启动
self.__active = True

# 启动事件处理线程
self.__thread.start()

# 启动计时器,计时器事件间隔默认设定为1秒
self.__timer.start(1000)
if timer:
self.__timer.start(1000)

#----------------------------------------------------------------------
def stop(self):
Expand Down Expand Up @@ -245,17 +249,21 @@ def __runTimer(self):
sleep(self.__timerSleep)

#----------------------------------------------------------------------
def start(self):
"""引擎启动"""
def start(self, timer=True):
"""
引擎启动
timer:是否要启动计时器
"""
# 将引擎设为启动
self.__active = True

# 启动事件处理线程
self.__thread.start()

# 启动计时器,计时器事件间隔默认设定为1秒
self.__timerActive = True
self.__timer.start()
if timer:
self.__timerActive = True
self.__timer.start()

#----------------------------------------------------------------------
def stop(self):
Expand Down
22 changes: 15 additions & 7 deletions vn.trader/eventEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,20 @@ def __onTimer(self):
self.put(event)

#----------------------------------------------------------------------
def start(self):
"""引擎启动"""
def start(self, timer=True):
"""
引擎启动
timer:是否要启动计时器
"""
# 将引擎设为启动
self.__active = True

# 启动事件处理线程
self.__thread.start()

# 启动计时器,计时器事件间隔默认设定为1秒
self.__timer.start(1000)
if timer:
self.__timer.start(1000)

#----------------------------------------------------------------------
def stop(self):
Expand Down Expand Up @@ -245,17 +249,21 @@ def __runTimer(self):
sleep(self.__timerSleep)

#----------------------------------------------------------------------
def start(self):
"""引擎启动"""
def start(self, timer=True):
"""
引擎启动
timer:是否要启动计时器
"""
# 将引擎设为启动
self.__active = True

# 启动事件处理线程
self.__thread.start()

# 启动计时器,计时器事件间隔默认设定为1秒
self.__timerActive = True
self.__timer.start()
if timer:
self.__timerActive = True
self.__timer.start()

#----------------------------------------------------------------------
def stop(self):
Expand Down
2 changes: 1 addition & 1 deletion vn.trader/vtEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MainEngine(object):
def __init__(self):
"""Constructor"""
# 创建事件引擎
self.eventEngine = EventEngine2()
self.eventEngine = EventEngine()
self.eventEngine.start()

# 创建数据引擎
Expand Down

0 comments on commit ac190f5

Please sign in to comment.