Commit c5d018be authored by Bas Lijnse's avatar Bas Lijnse

Fixed SDS notification based on system clock

parent ff8ebea6
Pipeline #23830 passed with stage
in 5 minutes and 10 seconds
......@@ -273,10 +273,13 @@ where
where
getTimeoutFromClock` :: (!SDSNotifyRequest, !Timespec) -> Maybe Timeout
getTimeoutFromClock` (snr=:{cmpParam=(ts :: ClockParameter Timespec)}, reqTimespec)
| startsWith "$IWorld:timespec$" snr.reqSDSId && ts.interval <> zero
| dependsOnClock snr && ts.interval <> zero
# fire = iworldTimespecNextFire now reqTimespec ts
= Just (max 0 (toMs fire - toMs now))
= mt
getTimeoutFromClock` _ = mt
dependsOnClock :: !SDSNotifyRequest -> Bool
dependsOnClock snr = indexOf "$IWorld:timespec$" snr.reqSDSId > 0
toMs x = x.tv_sec * 1000 + x.tv_nsec / 1000000
......@@ -3,6 +3,9 @@ module iTasks.Internal.IWorld.UnitTests
import Data.Either
import iTasks.Util.Testing
import iTasks.Internal.IWorld
import System.Time
derive gPrint Timespec
testInitIWorld = assertWorld "Init IWorld" id sut
where
......@@ -16,6 +19,22 @@ where
# world = destroyIWorld iworld
= (True,world)
tests = [testInitIWorld]
testIworldTimespecNextFireZero = assertEqual "Next Fire Zero" exp sut
where
exp = {tv_sec=12319,tv_nsec=100}
sut = iworldTimespecNextFire
{tv_sec=12319,tv_nsec=100}
{tv_sec=12314,tv_nsec=50}
{start={tv_sec=0,tv_nsec=1},interval={tv_sec=0,tv_nsec=0}}
testIworldTimespecNextFireOne= assertEqual "Next Fire One" exp sut
where
exp = {tv_sec=12315,tv_nsec=1}
sut = iworldTimespecNextFire
{tv_sec=12319,tv_nsec=100}
{tv_sec=12314,tv_nsec=50}
{start={tv_sec=0,tv_nsec=1},interval={tv_sec=1,tv_nsec=0}}
tests = [testInitIWorld,testIworldTimespecNextFireZero, testIworldTimespecNextFireOne]
Start world = runUnitTests tests world
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment