this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add simulated?/0 and monotonic_time/0

garrison 457f2cab 067c6faf

+35
+15
lib/trinity/sim.ex
··· 1 + defmodule Trinity.Sim do 2 + alias Trinity.Scheduler.Simulation 3 + import Trinity.Scheduler, only: [simulation_key: 0] 4 + 5 + @spec get_sim :: Simulation.t | nil 6 + defp get_sim, do: Process.get(simulation_key()) 7 + 8 + @spec simulated? :: boolean 9 + def simulated? do 10 + case get_sim() do 11 + nil -> false 12 + _sim -> true 13 + end 14 + end 15 + end
+20
lib/trinity/sim_system.ex
··· 1 + defmodule Trinity.SimSystem do 2 + alias Trinity.Scheduler.Simulation 3 + import Trinity.Scheduler, only: [simulation_key: 0] 4 + 5 + @spec get_sim :: Simulation.t | nil 6 + defp get_sim, do: Process.get(simulation_key()) 7 + 8 + @spec monotonic_time :: integer 9 + def monotonic_time do 10 + case get_sim() do 11 + nil -> System.monotonic_time() 12 + _sim -> sim_monotonic_time() 13 + end 14 + end 15 + 16 + defp sim_monotonic_time do 17 + %{now: now} = get_sim() 18 + :atomics.get(now, 1) 19 + end 20 + end