Ignore:
Timestamp:
Feb 23, 2010, 7:42:55 PM (12 years ago)
Author:
arnold
Message:

some bug fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/PeerToPeerManager_NEW/P2PManagerBase_NEW.cs

    r1170 r1173  
    348348            else
    349349            {
    350                 AllocateJobs();
     350                /* edited by Arnold - 2010.02.23 */
     351                // because parallel incoming free workers could run
     352                // into concurrence in this method, so some workers
     353                // could get more than one job - so they have to
     354                // queue the additional jobs.
     355                lock (this)
     356                {
     357                    AllocateJobs();
     358                }
    351359            }
    352360
     
    414422                this.startWorkingTime = DateTime.Now;
    415423
    416             /* edited by Arnold - 2010.02.23 */
    417             // because parallel incoming free workers could run
    418             // into concurrence in this method, so some workers
    419             // could get more than one job - so they have to
    420             // queue the additional jobs.
    421             lock (freePeers)
    422             {
    423                 foreach (PeerId worker in freePeers)
    424                 {
    425                     byte[] serializedNewJob = this.distributableJobControl.Pop(out temp_jobId);
    426                     if (serializedNewJob != null) // if this is null, there are no more JobParts on the main stack!
    427                     {
    428                         this.jobsWaitingForAcceptanceInfo.Add(temp_jobId, worker);
    429                         // get actual subscriber/worker and send the new job
    430                         base.p2pControl.SendToPeer(JobMessages.CreateJobPartMessage(temp_jobId, serializedNewJob), worker);
    431 
    432                         if (OnNewJobAllocated != null)
    433                             OnNewJobAllocated(temp_jobId);
    434 
    435                         // set free worker to busy in the peerManagement class
    436                         ((WorkersManagement)this.peerManagement).SetFreeWorkerToBusy(worker);
    437 
    438                         GuiLogging("Job '" + temp_jobId.ToString() + "' were sent to worker id '" + worker.ToString() + "'", NotificationLevel.Info);
    439                         i++;
    440                     }
    441                     else
    442                     {
    443                         GuiLogging("No more jobs left. So wait for the last results, than close this task.", NotificationLevel.Debug);
    444                         if (OnNoMoreJobsLeft != null)
    445                             OnNoMoreJobsLeft();
    446                     }
    447                     GuiLogging(i + " Job(s) allocated to worker(s).", NotificationLevel.Debug);
    448                 } // end foreach
    449             }
     424            foreach (PeerId worker in freePeers)
     425            {
     426                byte[] serializedNewJob = this.distributableJobControl.Pop(out temp_jobId);
     427                if (serializedNewJob != null) // if this is null, there are no more JobParts on the main stack!
     428                {
     429                    this.jobsWaitingForAcceptanceInfo.Add(temp_jobId, worker);
     430                    // get actual subscriber/worker and send the new job
     431                    base.p2pControl.SendToPeer(JobMessages.CreateJobPartMessage(temp_jobId, serializedNewJob), worker);
     432
     433                    if (OnNewJobAllocated != null)
     434                        OnNewJobAllocated(temp_jobId);
     435
     436                    // set free worker to busy in the peerManagement class
     437                    ((WorkersManagement)this.peerManagement).SetFreeWorkerToBusy(worker);
     438
     439                    GuiLogging("Job '" + temp_jobId.ToString() + "' were sent to worker id '" + worker.ToString() + "'", NotificationLevel.Info);
     440                    i++;
     441                }
     442                else
     443                {
     444                    GuiLogging("No more jobs left. So wait for the last results, than close this task.", NotificationLevel.Debug);
     445                    if (OnNoMoreJobsLeft != null)
     446                        OnNoMoreJobsLeft();
     447                }
     448                GuiLogging(i + " Job(s) allocated to worker(s).", NotificationLevel.Debug);
     449            } // end foreach
    450450        }
    451451
Note: See TracChangeset for help on using the changeset viewer.