示例#1
0
 private void ProcessSubJobs(JobProcessor2 jobProcessor, string requestMsgId, BlockingCollection <PointInt> subJobQ,
                             MessageQueue outQ, CancellationToken ct)
 {
     while (!ct.IsCancellationRequested)
     {
         try
         {
             if (subJobQ.TryTake(out PointInt position, Timeout.Infinite, ct))
             {
                 ProcessSubJob(jobProcessor, position, requestMsgId, outQ);
             }
         }
         catch (TaskCanceledException)
         {
             break;
         }
         catch (OperationCanceledException)
         {
             break;
         }
         catch (Exception e)
         {
             Console.WriteLine($"Process Lines, instance:{jobProcessor.InstanceNum} got error: {e.Message}.");
         }
     }
 }
示例#2
0
        private JobProcessor2 CreateJobProcessor(FJobRequest fJobRequest, int instanceNum)
        {
            FGenJob       job    = CreateJob(fJobRequest);
            JobProcessor2 result = new JobProcessor2(job, instanceNum);

            return(result);
        }
示例#3
0
        //private void AddLines(int lineCnt,  BlockingCollection<int> lineQ)
        //{
        //	int cnt = (lineCnt + 1)/ 2;

        //	int lLine;
        //	int hLine;
        //	if (lineCnt % 2 != 0)
        //	{
        //		_lineQ.Add(cnt);
        //		lLine = cnt - 1;
        //		hLine = cnt + 1;
        //		cnt--;
        //	}
        //	else
        //	{
        //		lLine = cnt;
        //		hLine = cnt + 1;
        //	}

        //	for (int cntr = 0; cntr < cnt; cntr++)
        //	{
        //		_lineQ.Add(lLine--);
        //		_lineQ.Add(hLine++);
        //	}
        //}

        Tuple <JobProcessor2, Task> BuildLineProcessor(FJobRequest fJobRequest, int instanceNum, string requestMsgId, BlockingCollection <PointInt> subJobQ,
                                                       MessageQueue outQ, CancellationToken ct)
        {
            JobProcessor2 jobProcessor = CreateJobProcessor(fJobRequest, instanceNum);
            Task          t            = Task.Run(() => ProcessSubJobs(jobProcessor, requestMsgId, subJobQ, outQ, ct));

            Tuple <JobProcessor2, Task> result = new Tuple <JobProcessor2, Task>(jobProcessor, t);

            return(result);
        }
示例#4
0
        private void ProcessSubJob(JobProcessor2 jobProcessor, PointInt position, string requestMsgId, MessageQueue outQ)
        {
            int jobId = jobProcessor.FGenJob.JobId;

            //int w = jobProcessor.FGenJob.Area.W();

            //uint[] counts = jobProcessor.GetCountsForLine(linePtr);

            SubJobResult subJobResult = jobProcessor.GetEmptySubJobResult();

            jobProcessor.FillCountsForBlock(position, subJobResult);
            //Debug.WriteLine(ReportSampleOfCounts(subJobResult.Counts));

            FJobResult fJobResult = GetResultFromSubJob(jobId, position, subJobResult);

            Message r = new Message(fJobResult)
            {
                CorrelationId = requestMsgId
            };

            Console.WriteLine($"Sending a response message with corId = {FMsgId(requestMsgId)}, instance:{jobProcessor.InstanceNum}.");
            outQ.Send(r);
        }