@@ -102,8 +102,8 @@ enum JobPriority_t
102102#define TP_MAX_POOL_THREADS 64
103103struct ThreadPoolStartParams_t
104104{
105- ThreadPoolStartParams_t ( bool bIOThreads = false , unsigned nThreads = -1 , int *pAffinities = NULL , ThreeState_t fDistribute = TRS_NONE, unsigned nStackSize = -1 , int iThreadPriority = SHRT_MIN, bool bHeavyLoad = false )
106- : bIOThreads( bIOThreads ), nThreads( nThreads ), fDistribute ( fDistribute ), nStackSize( nStackSize ), iThreadPriority( iThreadPriority ), nThreadsMax( -1 ), bHeavyLoad( bHeavyLoad )
105+ ThreadPoolStartParams_t ( bool bIOThreads = false , unsigned nThreads = -1 , int *pAffinities = NULL , ThreeState_t fDistribute = TRS_NONE, unsigned nStackSize = -1 , int iThreadPriority = SHRT_MIN )
106+ : bIOThreads( bIOThreads ), nThreads( nThreads ), fDistribute ( fDistribute ), nStackSize( nStackSize ), iThreadPriority( iThreadPriority ), nThreadsMax( -1 )
107107 {
108108 bExecOnThreadPoolThreadsOnly = false ;
109109
@@ -129,7 +129,6 @@ struct ThreadPoolStartParams_t
129129 bool bIOThreads : 1 ;
130130 bool bUseAffinityTable : 1 ;
131131 bool bExecOnThreadPoolThreadsOnly : 1 ;
132- bool bHeavyLoad : 1 ;
133132};
134133
135134// -----------------------------------------------------------------------------
@@ -930,7 +929,7 @@ class CParallelProcessor
930929
931930 if ( nJobs > 1 )
932931 {
933- if ( m_iBatchSize != 1 )
932+ if ( m_iBatchSize != 1 )
934933 {
935934 m_iBatchSize = nItems / nJobs;
936935 m_iLeftOver = nItems % nJobs;
@@ -940,7 +939,7 @@ class CParallelProcessor
940939 CJob **jobs = (CJob **)stackalloc ( nJobs * sizeof (CJob **) );
941940 int i = nJobs;
942941
943- while ( i-- )
942+ while ( i-- )
944943 {
945944#if 1
946945 jobs[i] = pThreadPool->QueueCall ( this , &CParallelProcessor<ITEM_TYPE, ITEM_PROCESSOR_TYPE>::DoExecute );
@@ -959,7 +958,7 @@ class CParallelProcessor
959958 }
960959 else
961960 {
962- m_iBatchSize = 1 ;
961+ m_iBatchSize = nItems ;
963962 DoExecute ();
964963 }
965964#if MEASURE_PARALLEL_WORK
@@ -983,18 +982,26 @@ class CParallelProcessor
983982 {
984983 m_ItemProcessor.Begin ();
985984
986- int iBatchSize = m_iBatchSize;
987- if (iBatchIndex == m_iBatchCount - 1 )
988- {
989- iBatchSize += m_iLeftOver;
990- }
991-
992- for (int i = 0 ; i < iBatchSize; i++)
985+ while (true )
993986 {
987+ int iBatchSize = m_iBatchSize;
988+ if ( iBatchIndex == m_iBatchCount - 1 )
989+ {
990+ iBatchSize += m_iLeftOver;
991+ }
992+
993+ for ( int i = 0 ; i < iBatchSize; i++ )
994+ {
994995#if MEASURE_PARALLEL_WORK
995- ++work;
996+ ++work;
996997#endif
997- m_ItemProcessor.Process ( *(m_pItems + (iBatchIndex * m_iBatchSize + i)) );
998+ m_ItemProcessor.Process ( *( m_pItems + ( iBatchIndex * m_iBatchSize + i ) ) );
999+ }
1000+ iBatchIndex = m_iBatchIndex++;
1001+ if ( iBatchIndex >= m_iBatchCount )
1002+ {
1003+ break ;
1004+ }
9981005 }
9991006
10001007 m_ItemProcessor.End ();
@@ -1021,7 +1028,6 @@ inline void ParallelProcess( const char *pszDescription, ITEM_TYPE *pItems, unsi
10211028 CParallelProcessor<ITEM_TYPE, CFuncJobItemProcessor<ITEM_TYPE> > processor ( pszDescription );
10221029 processor.m_ItemProcessor .Init ( pfnProcess, pfnBegin, pfnEnd );
10231030 processor.Run ( pItems, nItems, nMaxParallel );
1024-
10251031}
10261032
10271033template <typename ITEM_TYPE, typename OBJECT_TYPE, typename FUNCTION_CLASS >
0 commit comments