コード例 #1
0
 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
         };
     }));
 }
コード例 #2
0
 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;
 }
コード例 #3
0
ファイル: JobManager.cs プロジェクト: kirannadell/ironfoundry
 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();
     }
 }
コード例 #4
0
ファイル: JobManager.cs プロジェクト: isabella232/if_warden
 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();
     }
 }
コード例 #5
0
        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()
                };
            }));
        }