public async Task Run()
        {
            var ioService   = new IoServiceScheduler();
            var threadPool  = new IoServiceThreadPoolScheduler(ioService);
            var proxyEngine = new ProxyEngine(threadPool);

            ILibraryActor library = new LibraryActor();

            library = proxyEngine.CreateProxy(library);

            IResultProcessorActor resultProcessorActor = new PrintTopWordsProcessorActor();

            resultProcessorActor = proxyEngine.CreateProxy(resultProcessorActor);

            ICountWordAggregateActor aggregateWordCountActor = new WordCountAggregateActor(resultProcessorActor, BookLinesParserActor.NUMBER_OF_CONSUMERS);

            aggregateWordCountActor = proxyEngine.CreateProxy(aggregateWordCountActor);

            IBookLinesParserActor linesParserActor = new BookLinesParserActor(library, new BookLineConsumerFactory(aggregateWordCountActor, proxyEngine));

            linesParserActor = proxyEngine.CreateProxy(linesParserActor);

            library.AddBook(BOOK_NAME);

            await linesParserActor.ProcessLastBook().ConfigureAwait(false);


            linesParserActor.Complete();

            await resultProcessorActor.Completed;
        }
 private void createActors()
 {
     m_player1 = new AsyncPlayer(PLAYER_1_NAME);
     m_player2 = new AsyncPlayer(PLAYER_2_NAME);
     m_player1 = m_proxyEngine.CreateProxy(m_player1);
     m_player2 = m_proxyEngine.CreateProxy(m_player2);
 }
Example #3
0
        public virtual IBookLineConsumerActor CreateConsumer(int consumerId)
        {
            IBookLineConsumerActor consumer = new CountWordsInLineActor(consumerId, m_aggregateActor);

            consumer = m_proxyEngine.CreateProxy(consumer);
            return(consumer);
        }
Example #4
0
        private static void runSimpleUploaderActor()
        {
            const int NUMBER_OF_THREADS = 1;
            var       ioService         = new IoServiceScheduler();
            var       primaryScheduler  = new IoServiceThreadPoolScheduler(ioService, NUMBER_OF_THREADS);
            var       proxyScheduler    = new ProxyScheduler(primaryScheduler);

            var proxyEngine         = new ProxyEngine(primaryScheduler);
            var simpleUploaderActor = new SimpleUploaderActor();

            var uploaderActorProxy = proxyEngine.CreateProxy <IService>(simpleUploaderActor);

            runSimpleUploader(uploaderActorProxy);
        }