/// <summary> /// Creates a new shared counter. /// </summary> /// <param name="runtime">PSharpRuntime</param> /// <param name="value">Initial value</param> public static ISharedCounter Create(PSharpRuntime runtime, int value = 0) { if (runtime is ProductionRuntime) { return(new ProductionSharedCounter(value)); } else if (runtime is TestingServices.TestingRuntime) { return(new MockSharedCounter(value, runtime as TestingRuntime)); } else { throw new RuntimeException("Unknown runtime object of type: " + runtime.GetType().Name + "."); } }
/// <summary> /// Creates a new shared dictionary. /// </summary> /// <param name="runtime">PSharpRuntime</param> public static ISharedDictionary <TKey, TValue> Create <TKey, TValue>(PSharpRuntime runtime) { if (runtime is ProductionRuntime) { return(new ProductionSharedDictionary <TKey, TValue>()); } else if (runtime is TestingServices.TestingRuntime) { return(new MockSharedDictionary <TKey, TValue>(null, runtime as TestingRuntime)); } else { throw new RuntimeException("Unknown runtime object of type: " + runtime.GetType().Name + "."); } }
/// <summary> /// Creates a new shared dictionary. /// </summary> /// <param name="comparer">Comparer for keys</param> /// <param name="runtime">PSharp runtime</param> public static ISharedDictionary <TKey, TValue> Create <TKey, TValue>(IEqualityComparer <TKey> comparer, PSharpRuntime runtime) { if (runtime is StateMachineRuntime) { return(new ProductionSharedDictionary <TKey, TValue>(comparer)); } else if (runtime is TestingServices.BugFindingRuntime) { return(new MockSharedDictionary <TKey, TValue>(comparer, runtime as BugFindingRuntime)); } else { throw new RuntimeException("Unknown runtime object of type: " + runtime.GetType().Name + "."); } }
/// <summary> /// Creates a new shared register. /// </summary> /// <param name="runtime">PSharpRuntime</param> /// <param name="value">Initial value</param> public static ISharedRegister <T> Create <T>(PSharpRuntime runtime, T value = default) where T : struct { if (runtime is ProductionRuntime) { return(new ProductionSharedRegister <T>(value)); } else if (runtime is TestingServices.TestingRuntime) { return(new MockSharedRegister <T>(value, runtime as TestingRuntime)); } else { throw new RuntimeException("Unknown runtime object of type: " + runtime.GetType().Name + "."); } }