舌足らずですみません。コードはこんな感じです。
threadFunctionは単なる加算値、joinFunctionは集計処理です。
コアは物理2論理4です。
template< class ArgType >
void Reduce( std::vector< ArgType >& threadArgs, void* (*threadFunction)(void*), void (*joinFunction)(std::vector< ArgType >&) )
{
const size_t threadCount = threadArgs.size();
threads.resize( threadCount );
std::vector< void* > voidPtrArgs = CastArgsToVoidPtrs( threadArgs );
for ( int threadIndex = 0; threadIndex < threadCount; ++threadIndex )
{
sched_param schedParam;
schedParam.sched_priority = sched_get_priority_max( SCHED_FIFO );
pthread_attr_t threadAttribute;
pthread_attr_init( & threadAttribute );
pthread_attr_setschedpolicy( & threadAttribute, schedPolicy );
pthread_attr_setinheritsched( & threadAttribute, PTHREAD_EXPLICIT_SCHED );
pthread_t& thread = threads[ threadIndex ];
pthread_setschedparam( thread, schedPolicy, & schedParam );
pthread_create( & thread, & threadAttribute, threadFunction, voidPtrArgs[ threadIndex ] );
}
for ( int threadIndex = 0; threadIndex < threadCount; ++threadIndex )
{
pthread_t thread = threads[ threadIndex ];
pthread_join( thread, NULL );
}
joinFunction( threadArgs );
}
C++相談室 part135
■ このスレッドは過去ログ倉庫に格納されています
248デフォルトの名無しさん (ワッチョイ 9a91-Aj1d)
2018/04/23(月) 22:42:58.69ID:7US5BnQm0■ このスレッドは過去ログ倉庫に格納されています
ニュース
- 【W杯】韓国警察、「洪明甫(ホン・ミョンボ)監督選任」関連でサッカー協会を捜査中…「積極的に進める」 [ホイミン★]
- 亀梨和也が田中みな実と結婚発表 妊娠も「新しい命も授かっています」ファンクラブサイトで ★3 [首都圏の虎★]
- 亀梨和也が田中みな実と結婚発表 妊娠も「新しい命も授かっています」ファンクラブサイトで ★4 [首都圏の虎★]
- 【W杯】韓国警察、「洪明甫(ホン・ミョンボ)監督選任」関連でサッカー協会を捜査中…「積極的に進める」 [ホイミン★]
- 【W杯】ブラジル監督「日本戦は決勝のつもり」名将の最大級リスペクトにSNSで興奮殺到 [首都圏の虎★]
- 武田修宏 日本代表がブラジル戦に勝つ確率は「昔は10回やったら1回勝つか、というのが今回は5回やったら1回勝てるくらいの確率」 [冬月記者★]
- 【悲報】韓国警察、大統領令で韓国サッカー協会を強制捜査wwwwwwwwwwwwwww [404143271]
- やっぱりシルク姉さんがキュアエクレールなの?
- 27卒で内定先の初任給26万だけど
- 「バラエティ番組みたいに専門性無いYouTubeは見ない知識系だけ見る」ワイ、シンプルに退屈なのでYouTube見なくなる
- 【悲報】幻影旅団、現状の戦力ではヒソカに勝てずカキン王国の国宝を盗まなきゃ全員死亡が判明し終わるwwwwwwwwwwwwwwwwwwww [802034645]
- 【速報】亀梨和也、田中みな実が結婚、中出し妊娠 [398059782]