Skip to content

Commit

Permalink
Update Throttled.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Aug 13, 2024
1 parent b17218f commit 470b3c7
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/Throttled.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ using Pluto.WorkspaceManager: poll
@test x[] == 2

# Let's wait for the cooldown period to end
sleep(2dt)
sleep(3dt)
# nothing should have changed
@test x[] == 2

Expand All @@ -41,7 +41,7 @@ using Pluto.WorkspaceManager: poll
# so no leading timeout
@test x[] == 3
# the 2nd until 10th calls were still queued
sleep(2dt)
sleep(3dt)
@test x[] == 4


Expand All @@ -50,7 +50,7 @@ using Pluto.WorkspaceManager: poll
sleep(1.5dt)
end
@test x[] == 9
sleep(2dt)
sleep(3dt)
@test x[] == 9


Expand All @@ -74,7 +74,7 @@ using Pluto.WorkspaceManager: poll
@test x[] == 11


sleep(2dt)
sleep(3dt)
@test x[] == 11

###
Expand All @@ -84,13 +84,13 @@ using Pluto.WorkspaceManager: poll
@test x[] == 12
flush(tf)
@test x[] == 13
sleep(2dt)
sleep(3dt)
@test x[] == 13

####

tf()
@test poll(2dt, dt/60) do
@test poll(3dt, dt/60) do
x[] == 14
end
# immediately fire again, right after the last fire
Expand All @@ -103,7 +103,7 @@ using Pluto.WorkspaceManager: poll
@test x[] == 14

# but eventually, our call should get queued
sleep(2dt)
sleep(3dt)
@test x[] == 15

####
Expand All @@ -128,7 +128,7 @@ using Pluto.WorkspaceManager: poll
@test x[] == 0
sleep(.1dt)
@test x[] == 0
sleep(2dt)
sleep(3dt)
@test x[] == 1

@test tf.iscoolnow[]
Expand All @@ -139,13 +139,13 @@ using Pluto.WorkspaceManager: poll
tf()
Throttled.force_throttle_without_run(tf)
@test x[] == 2
sleep(2dt)
sleep(3dt)
@test x[] == 2


tf()
@test x[] == 3
sleep(2dt)
sleep(3dt)

####

Expand Down

0 comments on commit 470b3c7

Please sign in to comment.