私はクイックソートの並列化に取り組んでおり、スレッドは最初の試みです。スレッド化されていないバージョンは正しくソートされますが、スレッド化されたものはそうではありません (驚くことではありません)。私が興味深いと思ったのは、スレッドを削除したが、boost::bind 呼び出しを維持したとき、まだ機能しないことでした。boost::bind が私が望むものではない場合は、提案を提供してください。バインドは、関数をブースト スレッドで動作させる最も簡単な (または唯一の) 方法のようです。
void Quicksort( fVec &Array, const int Left, const int Right )
{
if( Right <= Left )
return;
int pivot = Left;
const int pivotNewIndex = Partition( Array, Left, Right, pivot );
// These function calls make it work fine
//Quicksort( Array, Left, pivotNewIndex - 1 );
//Quicksort( Array, pivotNewIndex + 1, Right );
// boost::bind calls only swaps one element, doesn't actually sort
boost::bind( &Quicksort, Array, Left, pivotNewIndex - 1 )();
boost::bind( &Quicksort, Array, pivotNewIndex + 1, Right )();
// threaded version that doesn't work, same as above
//boost::thread threadA( boost::bind( &Quicksort, Array, Left, pivotNewIndex - 1 ) );
//threadA.join();
//boost::thread threadB( boost::bind( &Quicksort, Array, pivotNewIndex + 1, Right ) );
//threadB.join();
}