public override Task <Response> HandleAsync() { log.Trace("Handle: '{0}' Script: '{1}'", request.Handle, request.Script); return(Task.Run <Response>(() => { IJobRunnable runnable = base.GetRunnableFor(request); uint jobId = jobManager.StartJobFor(runnable); // run async return new SpawnResponse { JobId = jobId }; })); }
public Job(uint jobId, IJobRunnable runnable) { if (jobId == default(uint)) { throw new ArgumentException("jobId must be > 0"); } if (runnable == null) { throw new ArgumentNullException("runnable"); } this.jobId = jobId; this.runnable = runnable; }
public uint StartJobFor(IJobRunnable runnable) { try { rwlock.EnterWriteLock(); uint jobId = GetNextJobID(); var job = new Job(jobId, runnable); jobs.Add(jobId, job); job.RunAsync(); return jobId; } finally { rwlock.ExitWriteLock(); } }
public uint StartJobFor(IJobRunnable runnable) { try { rwlock.EnterWriteLock(); uint jobId = GetNextJobID(); var job = new Job(jobId, runnable); jobs.Add(jobId, job); job.RunAsync(); return(jobId); } finally { rwlock.ExitWriteLock(); } }
public override Task <Response> HandleAsync() { log.Trace("Handle: '{0}' Script: '{1}'", request.Handle, request.Script); IJobRunnable runnable = base.GetRunnableFor(request); return(Task.Run <Response>(() => { IJobResult result = runnable.Run(); // run synchronously return new RunResponse { ExitStatus = (uint)result.ExitCode, Stdout = result.Stdout, Stderr = result.Stderr, Info = BuildInfoResponse() }; })); }