Skip to content

Commit d28c3dc

Browse files
committed
bump version rc
1 parent edcfea7 commit d28c3dc

6 files changed

Lines changed: 26 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ and this project adheres to
88

99
## [Unreleased]
1010

11+
## [0.5.0-rc.5] - 2025-10-26
12+
1113
### Performance
1214

1315
- Optimized VirtualClock event scheduling performance

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ File.write!("report.html", html)
300300
```elixir
301301
def deps do
302302
[
303-
{:gen_server_virtual_time, "~> 0.5.0-rc.4"}
303+
{:gen_server_virtual_time, "~> 0.5.0-rc.5"}
304304
]
305305
end
306306
```

generated/examples/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ <h2>🎓 Quick Start</h2>
349349
<pre style="background: #263238; color: #aed581; padding: 25px; border-radius: 10px; overflow-x: auto; margin-bottom: 30px;"><code class="language-elixir"># Add to mix.exs
350350
def deps do
351351
[
352-
{:gen_server_virtual_time, "~> 0.5.0-rc.4"}
352+
{:gen_server_virtual_time, "~> 0.5.0-rc.5"}
353353
]
354354
end
355355

generated/examples/reports/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ <h2>🚀 Getting Started</h2>
456456
<p>Install GenServerVirtualTime from Hex:</p>
457457
<pre style="background: #263238; color: #aed581; padding: 20px; border-radius: 8px; overflow-x: auto;"><code class="language-elixir">def deps do
458458
[
459-
{:gen_server_virtual_time, "~> 0.5.0-rc.4"}
459+
{:gen_server_virtual_time, "~> 0.5.0-rc.5"}
460460
]
461461
end</code></pre>
462462

lib/virtual_clock.ex

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,21 @@ defmodule VirtualClock do
551551
end
552552

553553
defp advance_loop(state, target_time, from) do
554+
# Calculate adaptive timeout based on time advance
555+
# For large advances, use longer timeout (max 30 seconds)
556+
time_advance = target_time - state.current_time
557+
ack_timeout_ms =
558+
if time_advance > 100_000 do
559+
# For advances > 100s, use adaptive timeout
560+
min(trunc(time_advance / 1000), 30_000)
561+
else
562+
2000
563+
end
564+
554565
# Set up timeout for ack wait - only if we have pending acks
555566
ack_timeout_ref =
556567
if MapSet.size(state.pending_acks) > 0 do
557-
Process.send_after(self(), {:ack_timeout, MapSet.to_list(state.pending_acks)}, 2000)
568+
Process.send_after(self(), {:ack_timeout, MapSet.to_list(state.pending_acks)}, ack_timeout_ms)
558569
else
559570
nil
560571
end
@@ -569,8 +580,10 @@ defmodule VirtualClock do
569580
new_state = %{state | current_time: target_time}
570581

571582
if MapSet.size(new_state.pending_acks) > 0 do
572-
# Still waiting for actors - store caller and wait for acks with longer timeout
573-
Process.send_after(self(), {:ack_timeout, MapSet.to_list(new_state.pending_acks)}, 2000)
583+
# Still waiting for actors - store caller and wait for acks with adaptive timeout
584+
time_advance = target_time - state.current_time
585+
ack_timeout_ms = if time_advance > 100_000, do: min(trunc(time_advance / 1000), 30_000), else: 2000
586+
Process.send_after(self(), {:ack_timeout, MapSet.to_list(new_state.pending_acks)}, ack_timeout_ms)
574587
{:noreply, %{new_state | advance_caller: from, target_time: target_time}}
575588
else
576589
# No pending acks - advance complete!
@@ -599,8 +612,10 @@ defmodule VirtualClock do
599612
# Don't immediately continue - wait for acks first, then check scheduler
600613
if MapSet.size(new_pending) > 0 do
601614
# Actors are processing - store caller and wait for all acks
602-
# Set up new timeout for the new acks
603-
Process.send_after(self(), {:ack_timeout, MapSet.to_list(new_pending)}, 2000)
615+
# Set up adaptive timeout for the new acks
616+
time_advance = target_time - next_time
617+
ack_timeout_ms = if time_advance > 100_000, do: min(trunc(time_advance / 1000), 30_000), else: 2000
618+
Process.send_after(self(), {:ack_timeout, MapSet.to_list(new_pending)}, ack_timeout_ms)
604619
{:noreply, %{new_state | advance_caller: from, target_time: target_time}}
605620
else
606621
# No actors to wait for - continue immediately

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule GenServerVirtualTime.MixProject do
22
use Mix.Project
33

4-
@version "0.5.0-rc.4"
4+
@version "0.5.0-rc.5"
55
@source_url "https://github.com/d-led/gen_server_virtual_time"
66

77
def project do

0 commit comments

Comments
 (0)