public static void Run() { // Enable autoflush of traces at the framework level Trace.AutoFlush = true; Log log = LogManager.CurrentLog; new TestLog(DriverState.TestName); //Hack: need a test log instance to record presence of not yet existent files StabilityTestDefinition testDefinition = new StabilityTestDefinition(DriverState.DriverParameters); IActionScheduler scheduler = (IActionScheduler)Activator.CreateInstance(testDefinition.SchedulerType); // HACK: Quality Vault doesn't support get arguments from command line. Passing StressRunHours through Environment variable instead. // Workaround TFS 822025 double stressRunHours = 0; if (double.TryParse(Environment.GetEnvironmentVariable("StressRunHours"), out stressRunHours)) { testDefinition.ExecutionTime = TimeSpan.FromHours(stressRunHours); } log.CurrentVariation.LogMessage("Starting Stress Run at: {0}.", DateTime.Now); log.CurrentVariation.LogMessage("Run should end at: {0}", DateTime.Now + testDefinition.ExecutionTime); log.CurrentVariation.LogMessage("Test name: {0}", DriverState.TestName); scheduler.Run(testDefinition); log.CurrentVariation.LogMessage("The test has ended itself."); log.CurrentVariation.LogResult(Result.Pass); log.CurrentVariation.Close(); }
/// <summary> /// Creates a <see cref="ICancelable"/> that will be in the canceled state /// when any of the source cancelables are in the canceled state. /// </summary> /// <param name="scheduler">The scheduler</param> /// <param name="cancelables">The cancelables instances to observe.</param> /// <returns>A new <see cref="ICancelable"/> that is linked to the source .</returns> public static ICancelable CreateLinkedCancelable(IActionScheduler scheduler, params ICancelable[] cancelables) { var cancellationTokens = cancelables.Select(c => c.Token).ToArray(); var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationTokens); return(new Cancelable(scheduler, cts)); }
/// <summary> /// Schedules an action to be invoked after an delay. /// </summary> /// <param name="scheduler">The scheduler</param> /// <param name="delay">The time period that has to pass before the action is invoked.</param> /// <param name="action">The action to perform.</param> /// <returns>A cancelable that can be used to cancel the action from being executed</returns> public static ICancelable ScheduleOnceCancelable(this IActionScheduler scheduler, TimeSpan delay, Action action) { var cancelable = new Cancelable(scheduler); scheduler.ScheduleOnce(delay, action, cancelable); return(cancelable); }
/// <summary> /// Schedules an action to be invoked after an delay. /// </summary> /// <param name="scheduler">The scheduler</param> /// <param name="millisecondsDelay">The time in milliseconds that has to pass before the action is invoked.</param> /// <param name="action">The action to perform.</param> /// <returns>A cancelable that can be used to cancel the action from being executed</returns> public static ICancelable ScheduleOnceCancelable(this IActionScheduler scheduler, int millisecondsDelay, Action action) { var cancelable = new Cancelable(scheduler); scheduler.ScheduleOnce(millisecondsDelay, action, cancelable); return(cancelable); }
/// <summary> /// Schedules an action to be invoked after an initial delay and then repeatedly. /// </summary> /// <param name="scheduler">The scheduler</param> /// <param name="initialDelay">The time period that has to pass before first invocation.</param> /// <param name="interval">The interval, i.e. the time period that has to pass between the action is invoked.</param> /// <param name="action">The action to perform.</param> /// <returns>A cancelable that can be used to cancel the action from being executed</returns> public static ICancelable ScheduleRepeatedlyCancelable(this IActionScheduler scheduler, TimeSpan initialDelay, TimeSpan interval, Action action) { var cancelable = new Cancelable(scheduler); scheduler.ScheduleRepeatedly(initialDelay, interval, action, cancelable); return(cancelable); }
public static async Task ScheduleAsync(this IActionScheduler actionScheduler, int estimateCost, Func <Task> action, CancellationToken cancellationToken, Func <int> actualCost = null, Func <Exception, int> exceptionCost = null) => await actionScheduler.ScheduleAsync(estimateCost, async() => { await action().ConfigureAwait(false); return(0); }, cancellationToken, actualCost == null?default(Func <int, int>) : _ => actualCost(), exceptionCost) .ConfigureAwait(false);
/// <summary> /// Schedules an action to be invoked after an initial delay and then repeatedly. /// </summary> /// <param name="scheduler">The scheduler</param> /// <param name="initialMillisecondsDelay">The time in milliseconds that has to pass before first invocation.</param> /// <param name="millisecondsInterval">The interval, i.e. the time in milliseconds that has to pass between the action is invoked.</param> /// <param name="action">The action to perform.</param> /// <returns>A cancelable that can be used to cancel the action from being executed</returns> public static ICancelable ScheduleRepeatedlyCancelable(this IActionScheduler scheduler, int initialMillisecondsDelay, int millisecondsInterval, Action action) { var cancelable = new Cancelable(scheduler); scheduler.ScheduleRepeatedly(initialMillisecondsDelay, millisecondsInterval, action, cancelable); return(cancelable); }
public UnboundedMailbox([NotNull] IActionScheduler scheduler) : base(scheduler) { if (scheduler == null) { throw new ArgumentNullException("scheduler"); } }
protected SchedulerBasedMailbox([NotNull] IActionScheduler scheduler) { if (scheduler == null) { throw new ArgumentNullException("scheduler"); } _actionScheduler = scheduler; }
public IRenderingTester(TWEngine engine, IActionScheduler scheduler, ParticlesBoxRenderer particleBoxRenderer) { this.engine = engine; this.scheduler = scheduler; this.particleBoxRenderer = particleBoxRenderer; scheduler.SetCurrentTime(TW.Graphics.TotalRunTime); engine.AddSimulator(new BasicSimulator(update)); engine.AddSimulator(new WorldRenderingSimulator()); }
public GameController( ITournamentPersistence tournamentPersistence, IOutgoingPlayerChannelFactory channelFactory, IApplicationConfiguration applicationConfiguration, IActionScheduler actionScheduler) { Tournament = tournamentPersistence.LoadTournament(); _channelFactory = channelFactory; _applicationConfiguration = applicationConfiguration; _actionScheduler = actionScheduler; }
public Bot(IActionScheduler actionScheduler, IAnswerSearchEngine answerSearchEngine, IConnectedClients clients, IBotClient botDataClient, IBotSettings settings) { Settings = settings; ActionScheduler = actionScheduler; AnswerSearchEngine = answerSearchEngine; BotDataClient = botDataClient; AnswerSearchEngine.SetApiKey(Settings.AnswerSearchApiKey); ConnectedClients = clients.ChatClients; CommandHandler = new BotCommandHandler(this); _ = ScheduleRepeatedMessages(); }
public AwaitAckHandler(IActionScheduler actionScheduler, IExpiryTimeCalculator expiryCalculator, INodeMarshaller marshaller, IOutgoingSocket actorSocket, Action <string> logger, AwaitConfiguration config) { _actionScheduler = actionScheduler; _disposeAction = new DisposableAction( () => { _actionScheduler.ExecuteAction += OneExecuteAction; }, () => { _actionScheduler.ExecuteAction -= OneExecuteAction; }); _expiryCalculator = expiryCalculator; _config = config; _marshaller = marshaller; _actorSocket = actorSocket; _logger = logger; }
protected ActorSystem([NotNull] string name, [NotNull] IBootstrapper bootstrapper) { if (bootstrapper == null) { throw new ArgumentNullException("bootstrapper"); } if (bootstrapper.UniqueNameCreator == null) { throw new ArgumentException("IBootstrapper.UniqueNameCreator was null", "bootstrapper"); } if (bootstrapper.LocalActorRefFactory == null) { throw new ArgumentException("IBootstrapper.LocalActorRefFactory was null", "bootstrapper"); } if (name == null) { throw new ArgumentNullException("name"); } if (name.Length == 0) { throw new ArgumentException("name"); } var nameLegal = new Regex("^[a-zA-Z0-9][a-zA-Z0-9-]*$"); if (!nameLegal.IsMatch(name)) { throw new ArgumentException( string.Format( "Invalid ActorSystem name [{0}], must contain only word characters (i.e. [a-zA-Z0-9] plus non-leading '-')", name), "name"); } _name = name; _rootPath = new RootActorPath("/"); _tempNodeHandler = new TempNodeHandler(_rootPath / "temp"); _settings = bootstrapper.Settings; _scheduler = bootstrapper.Scheduler; _uniqueNameCreator = bootstrapper.UniqueNameCreator; _localActorRefFactory = bootstrapper.LocalActorRefFactory; _deadLetters = bootstrapper.DeadLetterActorCreator(_rootPath / "_DeadLetter", this); _deadLettersMailbox = new DeadLetterMailbox(_deadLetters); _actionScheduler = bootstrapper.ActionScheduler; _defaultMailboxCreator = bootstrapper.DefaultMailboxCreator; _eventStream = new EventStream(this); var standardOutLogger = new StandardOutLogger(new ChildActorPath(_rootPath, "_StandardOutLogger", LocalActorRef.UndefinedInstanceId), this); _eventStream.StartStandardOutLogger(standardOutLogger, _settings.StandardOutLoggerSettings); _logSource = "ActorSystem:" + name; }
public void TestSchedule() { var scheduler = new IActionScheduler(); var value = 0; scheduler.SetCurrentTime(0); scheduler.SetTimeout(2, () => value = 5); scheduler.SetTimeout(3, () => value = 3); scheduler.SetTimeout(6, () => value++); scheduler.SetTimeout(6, () => value++); scheduler.SetTimeout(8, () => { value = 10; scheduler.SetTimeout(1, () => value++); }); scheduler.ExecuteActions(1); Assert.AreEqual(0, value); scheduler.ExecuteActions(1.5f); Assert.AreEqual(0, value); scheduler.ExecuteActions(2); Assert.AreEqual(5, value); scheduler.ExecuteActions(3); Assert.AreEqual(3, value); scheduler.ExecuteActions(4); Assert.AreEqual(3, value); scheduler.ExecuteActions(6); Assert.AreEqual(5, value); scheduler.ExecuteActions(6.5f); Assert.AreEqual(5, value); scheduler.ExecuteActions(8); Assert.AreEqual(10, value); scheduler.ExecuteActions(8.5f); Assert.AreEqual(10, value); scheduler.ExecuteActions(9); Assert.AreEqual(11, value); }
/// <summary> /// Initializes a new instance of the <see cref="Cancelable"/> class that will be cancelled after the specified amount of time. /// </summary> /// <param name="scheduler">The scheduler.</param> /// <param name="delay">The delay before the cancelable is canceled.</param> public Cancelable(IActionScheduler scheduler, TimeSpan delay) : this(scheduler) { CancelAfter(delay); }
[Obsolete("Only to be used from DeprecatedSchedulerExtensions. [1.0.0]")] //TODO: Remove this line and make it private when DeprecatedSchedulerExtensions is removed internal Cancelable(IActionScheduler scheduler, CancellationTokenSource source) { _source = source; _scheduler = scheduler; }
public NodeHandler(Node node, IActionScheduler actionScheduler) { _node = node; _actionScheduler = actionScheduler; }
/// <summary> /// Initializes a new instance of the <see cref="Cancelable"/> class. /// </summary> /// <param name="scheduler">TBD</param> public Cancelable(IActionScheduler scheduler) : this(scheduler, new CancellationTokenSource()) { //Intentionally left blank }
public StreamSchedulers(IActionScheduler readScheduler, IActionScheduler writeScheduler = null, IActionScheduler seekScheduler = null) { _readScheduler = readScheduler; _writeScheduler = writeScheduler; _seekScheduler = seekScheduler; }
[Obsolete("Only to be used from DeprecatedSchedulerExtensions.")] //TODO: Remove this line and make it private when DeprecatedSchedulerExtensions is removed internal Cancelable(IActionScheduler scheduler, CancellationTokenSource source) { _source = source; _scheduler = scheduler; }
public static void Schedule(this IActionScheduler actionScheduler, int cost, Action action, Func <int> actualCost = null, Func <Exception, int> exceptionCost = null) => actionScheduler.Schedule(cost, () => { action(); return(cost); }, actualCost == null ? default(Func <int, int>) : _ => actualCost(), exceptionCost);
/// <summary> /// Schedules an action to be invoked after an delay. /// The action will be wrapped so that it completes inside the currently active actor if it is called from within an actor. /// <remarks>Note! It's considered bad practice to use concurrency inside actors, and very easy to get wrong so usage is discouraged.</remarks> /// </summary> /// <param name="scheduler">The scheduler</param> /// <param name="millisecondsDelay">The time in milliseconds that has to pass before the action is invoked.</param> /// <param name="action">The action to perform.</param> /// <param name="cancelable">OPTIONAL. A cancelable that can be used to cancel the action from being executed. Defaults to <c>null</c></param> public static void ScheduleOnce(this IActionScheduler scheduler, int millisecondsDelay, Action action, ICancelable cancelable = null) { scheduler.ScheduleOnce(TimeSpan.FromMilliseconds(millisecondsDelay), action, cancelable); }
/// <summary> /// Creates a <see cref="ICancelable"/> that will be in the canceled state /// when any of the source cancelables are in the canceled state. /// </summary> /// <param name="scheduler">The scheduler</param> /// <param name="cancelables">The cancelables instances to observe.</param> /// <returns>A new <see cref="ICancelable"/> that is linked to the source .</returns> public static ICancelable CreateLinkedCancelable(IActionScheduler scheduler, params ICancelable[] cancelables) { var cancellationTokens = cancelables.Select(c => c.Token).ToArray(); var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationTokens); return new Cancelable(scheduler, cts); }
/// <summary> /// Initializes a new instance of the <see cref="Cancelable"/> class. /// </summary> /// <param name="scheduler"></param> public Cancelable(IActionScheduler scheduler) : this(scheduler, new CancellationTokenSource()) { //Intentionally left blank }
public static IAsyncResult BeginSchedule(this IActionScheduler actionScheduler, int estimateCost, Func <IAsyncResult> begin, Action <IAsyncResult> end, Func <int> actualCost = null, Func <Exception, int> exceptionCost = null) => actionScheduler.BeginSchedule(estimateCost, begin, ia => { end(ia); return(0); }, actualCost == null ? default(Func <int, int>) : _ => actualCost(), exceptionCost);
/// <summary> /// Schedules an action to be invoked after an initial delay and then repeatedly. /// The action will be wrapped so that it completes inside the currently active actor if it is called from within an actor /// <remarks>Note! It's considered bad practice to use concurrency inside actors, and very easy to get wrong so usage is discouraged.</remarks> /// </summary> /// <param name="scheduler">The scheduler</param> /// <param name="initialMillisecondsDelay">The time in milliseconds that has to pass before first invocation.</param> /// <param name="millisecondsInterval">The interval, i.e. the time in milliseconds that has to pass before the action is invoked again.</param> /// <param name="action">The action to perform.</param> /// <param name="cancelable">OPTIONAL. A cancelable that can be used to cancel the action from being executed. Defaults to <c>null</c></param> public static void ScheduleRepeatedly(this IActionScheduler scheduler, int initialMillisecondsDelay, int millisecondsInterval, Action action, ICancelable cancelable = null) { scheduler.ScheduleRepeatedly(TimeSpan.FromMilliseconds(initialMillisecondsDelay), TimeSpan.FromMilliseconds(millisecondsInterval), action, cancelable); }
public IndexModel(IBot bot, IRepository repository, IActionScheduler actionScheduler) { _bot = bot; _repository = repository; _actionScheduler = actionScheduler; }