source/train/XLeaderPS.cpp
void XLeaderPS::WaitForFinishing(const int* activeJobWorkers, const int isToUpdate)
{
    int activeCount = 0;
    for (int i = 0; i < jworkers.count; i++) {
        if (activeJobWorkers[i] > 0) {
            XWorker* worker = (XWorker*)jworkers[i];
            worker->DequeueFinishedJob();
            activeCount++;
            CheckNTErrors(worker->GetFinishedNumInQueue() == 0, "Incorrect job number!");
        }
    }

    if (activeCount > 0 && isToUpdate) {
        for (int i = 0; i < cworkers.count; i++) {
            XWorker* worker = (XWorker*)cworkers[i];
            for (int j = 0; j < serverModel.paramNum * activeCount; j++)
                worker->DequeueFinishedJob();
            CheckNTErrors(worker->GetFinishedNumInQueue() == 0, "Incorrect job number!");
        }

        for (int i = 0; i < uworkers.count; i++) {
            XWorker* worker = (XWorker*)uworkers[i];
            for (int j = 0; j < serverModel.paramNum; j++)
                worker->DequeueFinishedJob();
            CheckNTErrors(worker->GetFinishedNumInQueue() == 0, "Incorrect job number!");
        }

        for (int i = 0; i < bworkers.count; i++) {
            XWorker* worker = (XWorker*)bworkers[i];
            for (int j = 0; j < serverModel.paramNum; j++)
                worker->DequeueFinishedJob();
            CheckNTErrors(worker->GetFinishedNumInQueue() == 0, "Incorrect job number!");
        }
    }
}
/*
wait for finished states (i.e., all workers finish their jobs)
>> activeJobWorkers - indicates whether each job worker is active
>> isToUpdate - indicates whether the model is updated
*/
wait for finished states
>> activeJobWorkers - indicates whether each job worker is active
>> isToUpdate - indicates whether the model is updated
wait for finished states >> activeJobWorkers - indicates whether each job worker is active >> isToUpdate - indicates whether the model is updated
void XLeaderPS::WaitForFinishing(const int* activeJobWorkers, const int isToUpdate)
{
    int activeCount = 0;
    for (int i = 0; i < jworkers.count; i++) {
        if (activeJobWorkers[i] > 0) {
            XWorker* worker = (XWorker*)jworkers[i];
            worker->DequeueFinishedJob();
            activeCount++;
            CheckNTErrors(worker->GetFinishedNumInQueue() == 0, "Incorrect job number!");
        }
    }
    if (activeCount > 0 && isToUpdate) {
        for (int i = 0; i < cworkers.count; i++) {
            XWorker* worker = (XWorker*)cworkers[i];
            for (int j = 0; j < serverModel.paramNum * activeCount; j++)
                worker->DequeueFinishedJob();
            CheckNTErrors(worker->GetFinishedNumInQueue() == 0, "Incorrect job number!");
        }
        for (int i = 0; i < uworkers.count; i++) {
            XWorker* worker = (XWorker*)uworkers[i];
            for (int j = 0; j < serverModel.paramNum; j++)
                worker->DequeueFinishedJob();
            CheckNTErrors(worker->GetFinishedNumInQueue() == 0, "Incorrect job number!");
        }
        for (int i = 0; i < bworkers.count; i++) {
            XWorker* worker = (XWorker*)bworkers[i];
            for (int j = 0; j < serverModel.paramNum; j++)
                worker->DequeueFinishedJob();
            CheckNTErrors(worker->GetFinishedNumInQueue() == 0, "Incorrect job number!");
        }
    }
}
void XLeaderPS :: WaitForFinishing ( const int * activeJobWorkers , const int isToUpdate ) { int activeCount = 0 ; for ( int i = 0 ; i < jworkers . count ; i ++ ) { if ( activeJobWorkers [ i ] > 0 ) { XWorker * worker = ( XWorker * ) jworkers [ i ] ; worker -> DequeueFinishedJob ( ) ; activeCount ++ ; CheckNTErrors ( worker -> GetFinishedNumInQueue ( ) == 0 , " " ) ; } } if ( activeCount > 0 && isToUpdate ) { for ( int i = 0 ; i < cworkers . count ; i ++ ) { XWorker * worker = ( XWorker * ) cworkers [ i ] ; for ( int j = 0 ; j < serverModel . paramNum * activeCount ; j ++ ) worker -> DequeueFinishedJob ( ) ; CheckNTErrors ( worker -> GetFinishedNumInQueue ( ) == 0 , " " ) ; } for ( int i = 0 ; i < uworkers . count ; i ++ ) { XWorker * worker = ( XWorker * ) uworkers [ i ] ; for ( int j = 0 ; j < serverModel . paramNum ; j ++ ) worker -> DequeueFinishedJob ( ) ; CheckNTErrors ( worker -> GetFinishedNumInQueue ( ) == 0 , " " ) ; } for ( int i = 0 ; i < bworkers . count ; i ++ ) { XWorker * worker = ( XWorker * ) bworkers [ i ] ; for ( int j = 0 ; j < serverModel . paramNum ; j ++ ) worker -> DequeueFinishedJob ( ) ; CheckNTErrors ( worker -> GetFinishedNumInQueue ( ) == 0 , " " ) ; } } }
wait for finished states (i.e., all workers finish their jobs)
>> activeJobWorkers - indicates whether each job worker is active
>> isToUpdate - indicates whether the model is updated
wait for finished states ( i . e . all workers finish their jobs ) >> activeJobWorkers - indicates whether each job worker is active >> isToUpdate - indicates whether the model is updated