Esempio n. 1
0
        public static Spawner Spawner(IRouterConfig config)
        {
            return((id, props, parent) =>
            {
                var routeeProps = props.WithSpawner(null);
                var routerState = config.CreateRouterState();
                var wg = new AutoResetEvent(false);
                var routerProps = Actor.FromProducer(() => new RouterActor(routeeProps, config, routerState, wg));
                var routerId = ProcessRegistry.Instance.NextId();
                var router = Props.DefaultSpawner(routerId + "/router", routerProps, parent);
                wg.WaitOne(); //wait for the router to start

                var reff = new RouterProcess(router, routerState);
                var(pid, ok) = ProcessRegistry.Instance.TryAdd(routerId, reff);
                return pid;
            });
        }