修改EventEngine的启动函数,允许不启动Timer

This commit is contained in:
chenxy123 2017-01-04 22:08:44 +08:00
parent 5ef87e7798
commit ac190f5162
3 changed files with 31 additions and 15 deletions

View File

@ -109,8 +109,11 @@ class EventEngine(object):
self.put(event)
#----------------------------------------------------------------------
def start(self):
"""引擎启动"""
def start(self, timer=True):
"""
引擎启动
timer是否要启动计时器
"""
# 将引擎设为启动
self.__active = True
@ -118,7 +121,8 @@ class EventEngine(object):
self.__thread.start()
# 启动计时器计时器事件间隔默认设定为1秒
self.__timer.start(1000)
if timer:
self.__timer.start(1000)
#----------------------------------------------------------------------
def stop(self):
@ -245,8 +249,11 @@ class EventEngine2(object):
sleep(self.__timerSleep)
#----------------------------------------------------------------------
def start(self):
"""引擎启动"""
def start(self, timer=True):
"""
引擎启动
timer是否要启动计时器
"""
# 将引擎设为启动
self.__active = True
@ -254,8 +261,9 @@ class EventEngine2(object):
self.__thread.start()
# 启动计时器计时器事件间隔默认设定为1秒
self.__timerActive = True
self.__timer.start()
if timer:
self.__timerActive = True
self.__timer.start()
#----------------------------------------------------------------------
def stop(self):

View File

@ -109,8 +109,11 @@ class EventEngine(object):
self.put(event)
#----------------------------------------------------------------------
def start(self):
"""引擎启动"""
def start(self, timer=True):
"""
引擎启动
timer是否要启动计时器
"""
# 将引擎设为启动
self.__active = True
@ -118,7 +121,8 @@ class EventEngine(object):
self.__thread.start()
# 启动计时器计时器事件间隔默认设定为1秒
self.__timer.start(1000)
if timer:
self.__timer.start(1000)
#----------------------------------------------------------------------
def stop(self):
@ -245,8 +249,11 @@ class EventEngine2(object):
sleep(self.__timerSleep)
#----------------------------------------------------------------------
def start(self):
"""引擎启动"""
def start(self, timer=True):
"""
引擎启动
timer是否要启动计时器
"""
# 将引擎设为启动
self.__active = True
@ -254,8 +261,9 @@ class EventEngine2(object):
self.__thread.start()
# 启动计时器计时器事件间隔默认设定为1秒
self.__timerActive = True
self.__timer.start()
if timer:
self.__timerActive = True
self.__timer.start()
#----------------------------------------------------------------------
def stop(self):

View File

@ -23,7 +23,7 @@ class MainEngine(object):
def __init__(self):
"""Constructor"""
# 创建事件引擎
self.eventEngine = EventEngine2()
self.eventEngine = EventEngine()
self.eventEngine.start()
# 创建数据引擎