static void Main(string[] args) { if (!args.Any()) { ShowHelp(); } var settings = GetMasterWorkerSlaveSettings(args); Debug.WriteLine( $"Starting computation [{settings.ComputationLowerLimit}, {settings.ComputationUpperLimit}]" + $" with + {(settings.AsyncBus ? "async" : "sync")} bus" + $" and {settings.SlaveObjectsCount} slave worker(s)" ); //Create system var os = new ObjectSystem("/testSystem", new InMemoryBus(async: settings.AsyncBus)); //Create master os.Create(() => new MasterWorkerObject(settings.SlaveObjectsCount)); //Create subscriber to catch results sent from master var sub = os.Create(() => new ActionSubscriberObject<LogMessage>(msg => Console.WriteLine( $"{settings.ComputationLowerLimit},"+ $"{settings.ComputationUpperLimit}," + $"{settings.AsyncBus}," + $"{settings.SlaveObjectsCount}," + $"{msg.Message}," ) )); //Create generic obj and send some work parameters to the master var genericPub = os.Create(() => new GenericPublisherObject()); var work = Enumerable.Range((int)settings.ComputationLowerLimit, (int)settings.ComputationUpperLimit).ToArray(); genericPub.Publish(new PrimeOnPositionsToSumRequest(work)); Console.ReadLine(); }
static void Main() { //Create system var os = new ObjectSystem("/testSystem", new InMemoryBus(async: true)); var log = os.Create(() => new LoggerObject(), "logger/1"); var echo = os.Create(() => new EchoObject(), "echo"); //send ping to echo actor from 50 different objects var taskArray = Enumerable .Range(0, 50) .Select(i => os.Create(() => new AskAnswerPingObject()).Ping("/testSystem/echo")) .ToArray(); Task.WaitAll(taskArray); var log2 = os.Create(() => new LoggerObject(), "logger/2"); var log3 = os.Create(() => new LoggerObject(), "logger/3"); var slbp = os.Create(() => new SendingLogByPathObject()); //send log messages to loggers, specify them with path slbp.SendLogByPath("/testSystem/logger/2"); slbp.SendLogByPath("/testSystem/logger/2"); slbp.SendLogByPath("/testSystem/logger/2"); slbp.SendLogByPath("/testSystem/logger/3"); slbp.SendLogByPath("/testSystem/logger/3"); slbp.SendLogByPath("/testSystem/logger/3"); }