Exemplo n.º 1
0
        internal ActorSystem(string name, ActorsConfiguration?config)
        {
            Config = config ?? ActorsConfiguration.CreateDefault();

            Name        = ActorPath.Sanitize(name);
            Location    = new ActorPath($"{ActorPath.ProtocolName}://{Name}/");
            Actors      = new Dictionary <ActorPath, ActorContainer>();
            CancelToken = new CancellationTokenSource();
            Scheduler   = new Scheduler();

            Scheduler.AssignSystem(this);

            Root = new RootSupervisor(this);
            Root.Populate(this, ActorReferences.Nobody, Location);
            var rootcontainer = new ActorContainer(new ActorSchematic(() => new RootSupervisor(this)), Location.Name, Root);

            Actors.Add(Location, rootcontainer);
            Root.CallOnCreate();

            Log = new ActorLogger(Root);

            Lost = new LostLetters(this);
            Lost.Populate(this, new LocalActorReference(this, Root.Path), new ActorPath(Location.Path, "lost-letters"));
            var lostcontainer = new ActorContainer(new ActorSchematic(() => new LostLetters(this)), "lost-letters", Lost);

            Actors.Add(Lost.Path, lostcontainer);
            Lost.CallOnCreate();

            if (!Config.ManuallyStartScheduler)
            {
                Scheduler.Start();
            }

            SystemCount++;
        }