Esempio n. 1
0
 public MasterHub(WorkerConnectionGroupContext connectionContext)
 {
     this.workerConnectionContext = connectionContext;
 }
Esempio n. 2
0
        protected override async Task CreateCoWorkerAndExecuteAsync(IWorkerReceiver broadcaster, WorkerConnectionGroupContext workerConnection, string workerName, CancellationToken cancellationToken, TaskFailSignal failSignal)
        {
            var loopCount = maxWorkerPerProcess / workerSpawnCount;

            for (int i = 0; i < loopCount; i++)
            {
                // Worker CreateCoWorker
                logger.LogTrace("Send CreateWorker/Setup command to workers and wait complete message.");
                workerConnection.OnCreateCoWorkerAndSetup.Reset();
                broadcaster.CreateCoWorkerAndSetup(workerSpawnCount, workerName);
                await workerConnection.OnCreateCoWorkerAndSetup.WaitWithTimeoutAsync(options.Timeout, cancellationToken, failSignal.Task);

                // Worker Execute
                if (i == 0)
                {
                    logger.LogTrace("Send Execute command to workers.");
                    broadcaster.ExecuteUntilReceiveStop();
                }

                // Wait Spawn.
                await Task.Delay(TimeSpan.FromSeconds(workerSpawnSecond));
            }

            // Send Stop Command
            logger.LogTrace("Send Stop command to workers.");
            broadcaster.Stop();

            // Wait Execute Complete.
            await workerConnection.OnExecute.WaitWithTimeoutAsync(options.Timeout, cancellationToken, failSignal.Task);
        }
Esempio n. 3
0
 protected abstract Task CreateCoWorkerAndExecuteAsync(IWorkerReceiver broadcaster, WorkerConnectionGroupContext workerConnection, string workerName, CancellationToken cancellationToken, TaskFailSignal failSignal);
Esempio n. 4
0
        protected override async Task CreateCoWorkerAndExecuteAsync(IWorkerReceiver broadcaster, WorkerConnectionGroupContext workerConnection, string workerName, CancellationToken cancellationToken, TaskFailSignal failSignal)
        {
            // Worker CreateCoWorker
            logger.LogTrace("Send CreateWorker/Setup command to workers and wait complete message.");
            broadcaster.CreateCoWorkerAndSetup(workerPerProcess, workerName);
            await workerConnection.OnCreateCoWorkerAndSetup.WaitWithTimeoutAsync(options.Timeout, cancellationToken, failSignal.Task);

            // Worker Execute
            logger.LogTrace("Send Execute command to workers and wait complete message.");
            broadcaster.Execute(executePerWorker);
            await workerConnection.OnExecute.WaitWithTimeoutAsync(options.Timeout, cancellationToken, failSignal.Task);
        }