Exemplo n.º 1
0
        public void Execute(Action<IActorRuntime, ITestingRuntime> action, IScheduler scheduler)
        {
            runtime = new TestingActorRuntime(scheduler);

            // TODO: Remove this somehow.
            TaskHelper.runtime = runtime;

            var task = new Task(() =>
            {
                TestingActorRuntime.ActorBody<object>(
                    () =>
                    {
                        action(runtime, runtime);
                        return null;
                    },
                    runtime,
                    true);
            },
                CancellationToken.None,
                TaskCreationOptions.RunContinuationsAsynchronously);

            runtime.RegisterMainTask(task);

            task.Start(taskScheduler);

            task.Wait();
            runtime.WaitForAllActorsToTerminate();
        }
Exemplo n.º 2
0
 public ActorInfo(
     ActorId id,
     string name,
     Task task,
     CancellationTokenSource cts,
     TestingActorRuntime runtime)
 {
     this.id = id;
     this.task = task;
     this.name = name;
     this.cts = cts;
     Mailbox = new Mailbox<object>(this, runtime);
     terminateWaiters = new HashSet<ActorInfo>();
     exceptions = new List<Exception>();
 }