예제 #1
0
파일: Job.cpp 프로젝트: stden/IJE
void Job::waitForEvent(DWORD timeout)
{
    gatherInfo();
    testRestrictions();

    DWORD evnt;
    ULONG key;
    LPOVERLAPPED lpOverlapped;
    BOOL reslt = GetQueuedCompletionStatus(port.handle(),&evnt,&key,
        &lpOverlapped,timeout);
    if (reslt == 0) {
        DWORD err = GetLastError();
        tryApi(_T("GetQueuedCompletionStatus"),err == WAIT_TIMEOUT);
    } else {
        if (evnt == JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO)
            jobactive = false;
        else if (evnt == JOB_OBJECT_MSG_END_OF_JOB_TIME ||
            evnt == JOB_OBJECT_MSG_END_OF_PROCESS_TIME)
            res = JobResult(JobResult::TL,_T(""));
        else if (evnt == JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT)
            res = JobResult(JobResult::SV, Messages::RESULT_CHILD_PROCESS);
        else if (evnt == JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT ||
            evnt == JOB_OBJECT_MSG_JOB_MEMORY_LIMIT)
            res = JobResult(JobResult::ML,_T(""));
    }
    if (res.valid()) {
        tryApi(_T("TerminateJobObject"),
            TerminateJobObject(hJob,0) != 0);
    } else if (!active()) {
        DWORD code;
        tryApi(_T("GetExitCodeProcess"),
            GetExitCodeProcess(hMainProcess,&code) != 0);
        res = JobResult(JobResult::OK, _T(""));
    }
}
예제 #2
0
파일: Job.cpp 프로젝트: stden/IJE
void Job::testRestrictions()
{
    LONG jobTime = processTimeCounter.getLongValue();
    LONGLONG elapsedTime = elapsedTimeCounter.getLargeValue();
    if (timeLimit > 0 && jobTime*10000ULL > timeLimit) {
        res = JobResult(JobResult::TL,_T(""));
    }
    if (prevJobTime > 0) {
        LONG usedSinceLast = jobTime - prevJobTime;
        LONGLONG elapsedSinceLast = elapsedTime - prevElapsedTime;
        if (elapsedSinceLast > 0 && static_cast<double>(usedSinceLast)/elapsedSinceLast < cpuUsageIdle) {
            millisecondsIdle += elapsedSinceLast;
        }
    }
    if (idlenessLimit > 0 && millisecondsIdle*10000ULL > idlenessLimit) {
        res = JobResult(JobResult::IS,_T(""));
    }
    prevJobTime = jobTime;
    prevElapsedTime = elapsedTime;
}
예제 #3
0
파일: Job.cpp 프로젝트: stden/IJE
void Job::assignMainProcess(const Process &process)
{
    hMainProcess = process.processHandle();
    tryApi(_T("AssignProcessToJobObject"),
        AssignProcessToJobObject(hJob,hMainProcess) != 0);
    gatherInfo();
    initialElapsedTimeCounter = elapsedTimeCounter.getLargeValue();
    millisecondsIdle = 0;
    prevJobTime = -1;
    prevElapsedTime = -1;
    res = JobResult();
    jobactive = true;
}
예제 #4
0
파일: Job.cpp 프로젝트: stden/IJE
void Job::terminate()
{
    res = JobResult(JobResult::ER,Messages::RESULT_TERMINATED);
}
예제 #5
0
파일: Job.cpp 프로젝트: Rezesius/calamares
JobResult
JobResult::error( const QString& message, const QString& details )
{
    return JobResult( false, message, details );
}
예제 #6
0
파일: Job.cpp 프로젝트: Rezesius/calamares
JobResult
JobResult::ok()
{
    return JobResult( true, QString(), QString() );
}
예제 #7
0
파일: Job.cpp 프로젝트: calamares/calamares
JobResult
JobResult::internalError( const QString& message, const QString& details, int number )
{
    return JobResult( message, details, number ? number : GenericError );
}
예제 #8
0
파일: Job.cpp 프로젝트: calamares/calamares
JobResult
JobResult::error( const QString& message, const QString& details )
{
    return JobResult( message, details, GenericError );
}
예제 #9
0
파일: Job.cpp 프로젝트: calamares/calamares
JobResult
JobResult::ok()
{
    return JobResult( QString(), QString(), NoError );
}