舌足らずですみません。コードはこんな感じです。
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■ このスレッドは過去ログ倉庫に格納されています
ニュース
- 【米FRB】0.25%利下げ決定 3会合連続、雇用下支え [蚤の市★]
- テレビ朝日本社から20~30代の関連会社社員とみられる男性が転落し死亡 六本木けやき坂通りの通行人にはけが人なし [少考さん★]
- テレビ朝日 本社から男性が転落し死亡。関連会社社員か 当たった通行人が左肩軽傷 [阿弥陀ヶ峰★]
- 「残クレ」でマイホーム、国が銀行向け保険 新型住宅ローン普及促す -日経 ★3 [少考さん★]
- 小島瑠璃子さん、代表取締役を務める会社を破産申請 [牛丼★]
- 【ジャイアンツ】ファン感謝祭で阿部監督に「お前がやめろ!」とヤジが飛ぶ巨人の異常事態… [鉄チーズ烏★]
- 【朗報】VTuber、とうとうスパロボに参戦する
- 高橋洋一、終わる [523957489]
- 毎日菊花茶飲んでたら美肌になったよ
- 🏡ダブパン本仕込み~🍞🍞😅🍞🍞🏡
- 朝雑談
- 粗品「南原が3億も貰えんの?」 [279254606]
