doc
parent
c206823b30
commit
324f7acafe
|
@ -9,12 +9,21 @@ const CollectionUtils = preload("res://zfoo/util/CollectionUtils.gd")
|
||||||
|
|
||||||
const schedulerMap: Dictionary = {}
|
const schedulerMap: Dictionary = {}
|
||||||
|
|
||||||
|
|
||||||
|
# 固定延迟执行的任务,delay默认为毫秒
|
||||||
static func schedule(runnable: Runnable, delay: int) -> void:
|
static func schedule(runnable: Runnable, delay: int) -> void:
|
||||||
var triggerTimestamp = TimeUtils.currentTimeMillis() + delay
|
var triggerTimestamp = TimeUtils.currentTimeMillis() + delay
|
||||||
var definition = SchedulerDefinition.new(runnable, delay, triggerTimestamp, false)
|
var definition = SchedulerDefinition.new(runnable, delay, triggerTimestamp, false)
|
||||||
schedulerMap[definition] = null
|
schedulerMap[definition] = null
|
||||||
|
|
||||||
|
|
||||||
|
# 不断执行的周期循环任务,delay默认为毫秒
|
||||||
|
static func scheduleAtFixRate(runnable: Runnable, delay: int) -> void:
|
||||||
|
var triggerTimestamp = TimeUtils.currentTimeMillis() + delay
|
||||||
|
var definition = SchedulerDefinition.new(runnable, delay, triggerTimestamp, false)
|
||||||
|
schedulerMap[definition] = null
|
||||||
|
|
||||||
|
|
||||||
static func triggerPerSecond() -> void:
|
static func triggerPerSecond() -> void:
|
||||||
var timestamp = TimeUtils.currentTimeMillis()
|
var timestamp = TimeUtils.currentTimeMillis()
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,20 @@
|
||||||
extends Object
|
extends Object
|
||||||
|
|
||||||
|
|
||||||
|
# 一秒钟对应的纳秒数
|
||||||
|
const NANO_PER_SECOND: int = 1_000_000_000
|
||||||
|
# 一秒钟对应的毫秒数
|
||||||
|
const MILLIS_PER_SECOND: int = 1 * 1000
|
||||||
|
# 一分钟对应的毫秒数
|
||||||
|
const MILLIS_PER_MINUTE = 1 * 60 * MILLIS_PER_SECOND
|
||||||
|
# 一个小时对应的毫秒数
|
||||||
|
const MILLIS_PER_HOUR = 1 * 60 * MILLIS_PER_MINUTE
|
||||||
|
# 一天对应的毫秒数
|
||||||
|
const MILLIS_PER_DAY = 1 * 24 * MILLIS_PER_HOUR
|
||||||
|
# 一周对应的毫秒数
|
||||||
|
const MILLIS_PER_WEEK = 1 * 7 * MILLIS_PER_HOUR
|
||||||
|
|
||||||
|
|
||||||
const timestamp = [0]
|
const timestamp = [0]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue