Skip to content

Commit 5c2b825

Browse files
committed
more precise words
1 parent e89b94b commit 5c2b825

6 files changed

Lines changed: 133 additions & 105 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@ and this project adheres to
1313
### Added
1414

1515
- VirtualTimeGenStateMachine with full `:gen_statem` support
16-
- `start_link/3`, `start/3`, `call/3`, `cast/2`, `stop/3` functions for VirtualTimeGenStateMachine
17-
- Compilation warnings for global virtual clock operations to prevent race conditions
16+
- `start_link/3`, `start/3`, `call/3`, `cast/2`, `stop/3` functions for
17+
VirtualTimeGenStateMachine
18+
- Compilation warnings for global virtual clock operations to prevent race
19+
conditions
1820

1921
### Changed
2022

2123
- Optimized VirtualClock event scheduling by using asynchronous operations
2224
- Time backend is now internal and transparent to client code
23-
- VirtualTimeGenServer and VirtualTimeGenStateMachine functions now emit warnings when using global clock injection
25+
- VirtualTimeGenServer and VirtualTimeGenStateMachine functions now emit
26+
warnings when using global clock injection
2427
- Removed complex wrapper module causing callback conflicts
2528
- Now uses native Erlang `:gen_statem` directly
2629

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Test time-based GenServers instantly. Simulate actor systems with virtual time.
44
Model, simulate, analyze actor systems and generate boilerplate in various Actor
55
Model implementations: in Java, Rust, Pony, Go and C++.
66

7-
87
[![Hex.pm](https://img.shields.io/hexpm/v/gen_server_virtual_time.svg)](https://hex.pm/packages/gen_server_virtual_time)
98
[![Documentation](https://img.shields.io/badge/docs-hexdocs-blue.svg)](https://hexdocs.pm/gen_server_virtual_time)
109
[![CI](https://github.com/d-led/gen_server_virtual_time/workflows/CI/badge.svg)](https://github.com/d-led/gen_server_virtual_time/actions)
@@ -22,7 +21,10 @@ Model implementations: in Java, Rust, Pony, Go and C++.
2221
elixir scripts/century_backup_demo.exs
2322
```
2423

25-
Run the century backup demo to see virtual time in action - simulate 100 years of daily backups (36,525 backups) in milliseconds. [Source](scripts/century_backup_demo.exs). [Sample run](https://github.com/d-led/gen_server_virtual_time/actions/workflows/century-backup-demo.yml).
24+
Run the century backup demo to see virtual time in action - simulate 100 years
25+
of daily backups (36,525 backups) in milliseconds.
26+
[Source](scripts/century_backup_demo.exs).
27+
[Sample run](https://github.com/d-led/gen_server_virtual_time/actions/workflows/century-backup-demo.yml).
2628

2729
## 🚀 Code Generators
2830

lib/time_backend.ex

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ defmodule TimeBackend do
44
"""
55

66
@callback send_after(pid(), term(), non_neg_integer()) :: reference()
7+
# delay_ms: delay in milliseconds
78
@callback send_immediately(pid(), term()) :: :ok
89
@callback cancel_timer(reference()) :: non_neg_integer() | false
910
@callback sleep(non_neg_integer()) :: :ok
11+
# duration_ms: duration in milliseconds
1012
end
1113

1214
defmodule RealTimeBackend do
@@ -16,8 +18,8 @@ defmodule RealTimeBackend do
1618
@behaviour TimeBackend
1719

1820
@impl true
19-
def send_after(dest, message, delay) do
20-
Process.send_after(dest, message, delay)
21+
def send_after(dest, message, delay_ms) do
22+
Process.send_after(dest, message, delay_ms)
2123
end
2224

2325
@impl true
@@ -32,8 +34,8 @@ defmodule RealTimeBackend do
3234
end
3335

3436
@impl true
35-
def sleep(duration) do
36-
Process.sleep(duration)
37+
def sleep(duration_ms) do
38+
Process.sleep(duration_ms)
3739
end
3840
end
3941

@@ -44,9 +46,9 @@ defmodule VirtualTimeBackend do
4446
@behaviour TimeBackend
4547

4648
@impl true
47-
def send_after(dest, message, delay) do
49+
def send_after(dest, message, delay_ms) do
4850
clock = get_virtual_clock()
49-
VirtualClock.send_after(clock, dest, message, delay)
51+
VirtualClock.send_after(clock, dest, message, delay_ms)
5052
end
5153

5254
@impl true
@@ -64,10 +66,10 @@ defmodule VirtualTimeBackend do
6466
end
6567

6668
@impl true
67-
def sleep(duration) do
69+
def sleep(duration_ms) do
6870
# Schedule a wake-up message in virtual time and wait for it
6971
ref = make_ref()
70-
send_after(self(), {:__vtgs_sleep_done__, ref}, duration)
72+
send_after(self(), {:__vtgs_sleep_done__, ref}, duration_ms)
7173

7274
receive do
7375
{:__vtgs_sleep_done__, ^ref} -> :ok

0 commit comments

Comments
 (0)