Ejemplo n.º 1
0
        public CompositeActor(IActor[] actors, IStructSizeCounter counter, Func<Type, int> messageIdGetter)
        {
            if (actors.Length > MaxActors)
            {
                throw new ArgumentException($"Too many actors. Can composite only up to {MaxActors}");
            }

            var messageTypes = actors.Select(a => new ActorDescriptor(a))
                .SelectMany(descriptor => descriptor.HandledMessageTypes)
                .Distinct()
                .ToArray();

            Descriptor = new ActorDescriptor(messageTypes);
            _readers = actors.Select(a => new MessageReader(a, counter, messageIdGetter)).ToArray();
            _count = _readers.Length;

            _messageMap = BuildMessageMap(actors, messageIdGetter);
            _batchAware = actors.OfType<IBatchAware>().ToArray();
        }