瀏覽代碼

Refactored to use TimeUnitToMillis().

Brucey 1 年之前
父節點
當前提交
4b30c50ff3
共有 1 個文件被更改,包括 3 次插入17 次删除
  1. 3 17
      threadpool.mod/threadpool.bmx

+ 3 - 17
threadpool.mod/threadpool.bmx

@@ -327,26 +327,12 @@ Type TScheduledThreadPoolExecutor Extends TThreadPoolExecutor
 	bbdoc: Schedules a recurring command to run after a given initial delay, and subsequently with the given period.
 	End Rem
 	Method schedule(command:TRunnable, initialDelay:ULong, period:ULong, unit:ETimeUnit = ETimeUnit.Milliseconds)
-			Local now:ULong = CurrentUnixTime()
+		Local now:ULong = CurrentUnixTime()
 
 		Local newTask:TScheduledTask = New TScheduledTask
 
-		Local delayMs:ULong = initialDelay
-		Local periodMs:ULong = period
-		Select unit
-			Case ETimeUnit.Seconds
-				delayMs :* 1000
-				periodMs :* 1000
-			Case ETimeUnit.Minutes
-				delayMs :* 60000
-				periodMs :* 60000
-			Case ETimeUnit.Hours
-				delayMs :* 3600000
-				periodMs :* 3600000
-			Case ETimeUnit.Days
-				delayMs :* 86400000
-				periodMs :* 86400000
-		End Select
+		Local delayMs:ULong = TimeUnitToMillis(initialDelay, unit)
+		Local periodMs:ULong = TimeUnitToMillis(period, unit)
 
 		newTask.executeAt = now + delayMs
 		newTask.intervalMs = periodMs