SF Tracker [ 1628562 ] Maximum total jobs patch
Submitted By: Fredrik Svensson - svefredrik Incremented the libray versions and included some comments in the file configure.ac so that we do not bump the library version excessively, only the necessary numbers on the next release. git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@115 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
@@ -906,6 +906,7 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
int rc = EOUTOFMEM;
|
||||
|
||||
int tempId = -1;
|
||||
int totalJobs;
|
||||
|
||||
ThreadPoolJob *temp = NULL;
|
||||
|
||||
@@ -922,6 +923,13 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
|| ( job->priority == MED_PRIORITY )
|
||||
|| ( job->priority == HIGH_PRIORITY ) );
|
||||
|
||||
totalJobs = tp->highJobQ.size + tp->lowJobQ.size + tp->medJobQ.size;
|
||||
if (totalJobs >= tp->attr.maxJobsTotal) {
|
||||
fprintf(stderr, "total jobs = %d, too many jobs", totalJobs);
|
||||
ithread_mutex_unlock( &tp->mutex );
|
||||
return rc;
|
||||
}
|
||||
|
||||
if( jobId == NULL )
|
||||
jobId = &tempId;
|
||||
|
||||
@@ -1267,6 +1275,7 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
attr->minThreads = DEFAULT_MIN_THREADS;
|
||||
attr->schedPolicy = DEFAULT_POLICY;
|
||||
attr->starvationTime = DEFAULT_STARVATION_TIME;
|
||||
attr->maxJobsTotal = DEFAULT_MAX_JOBS_TOTAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1518,6 +1527,29 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
stats->totalIdleTime );}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: TPAttrSetMaxJobsTotal
|
||||
*
|
||||
* Description:
|
||||
* Sets the maximum number jobs that can be qeued totally.
|
||||
* Parameters:
|
||||
* attr - must be valid thread pool attributes.
|
||||
* maxJobsTotal - maximum number of jobs
|
||||
* Returns:
|
||||
* Always returns 0.
|
||||
*****************************************************************************/
|
||||
int TPAttrSetMaxJobsTotal( ThreadPoolAttr * attr,
|
||||
int maxJobsTotal ) {
|
||||
assert( attr != NULL );
|
||||
|
||||
if( attr == NULL ) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
attr->maxJobsTotal = maxJobsTotal;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ThreadPoolGetStats
|
||||
*
|
||||
|
Reference in New Issue
Block a user