Beispiel #1
0
/**
删除一个任务,在两个列表里删,ready和wait
**/
func Del(readyData *Entity.ReadyData, waitData *Entity.WaitData, key string) error {
	if readyData.Isset(key) {
		readyData.Del(key)
		//存储数据
		Store.SetData(readyData, waitData)
		return nil
	}
	if waitData.Isset(key) {
		waitData.Del(key)
		//存储数据
		Store.SetData(readyData, waitData)
		return nil
	}
	return Utils.LogErr(1000)
}
Beispiel #2
0
/**
检查进入等待状态的任务是否到期,到期后放入readyData
**/
func CheckWaitTask(readyData *Entity.ReadyData, waitData *Entity.WaitData) {
	c := time.Tick(time.Second)
	dataChange := false
	for _ = range c {
		for key, value := range *waitData {
			//已经到期的任务,放入readyData
			if value.Expired <= uint(time.Now().Unix()) {
				Utils.LogInfo("check do=%s\n", key)
				readyData.Add(key, value.Value, value.Expired)
				waitData.Del(key)
				dataChange = true
			}
		}
		if dataChange {
			//存储数据
			Store.SetData(readyData, waitData)
			dataChange = false
		}

	}

}