이것은 처음으로 boost thread 함수를 사용하는 것이고, 이전에는 다중 쓰레드로 작업하는 것에 대한 지식이 거의 없습니다. 나는 같은 함수에 두 개의 다른 변수를 전달할 수 있도록 초기 호출과 함께 함수의 두 번째 인스턴스를 실행하려고하는데, 이는 내 프로그램의 속도를 높이기를 바라고있다. 내가 가지고있는 코드는 내가boost :: thread의 함수에 인자를 건네줍니다.
'T *boost::get_pointer(const boost::scoped_ptr<T> &)' : could not deduce template argument for 'const boost::scoped_ptr<T> &' from 'const std::string'
여기 스레드 생성
string firstPart = recText.substr(1,(subPart1-1));
string secondPart = recText.substr(subPart1,subPart1);
boost::thread firstThread;
boost::thread secondThread;
firstThread = boost::thread(&Conversion::conversion,firstPart);
secondThread = boost::thread(&Conversion::conversion,secondPart);
firstThread.join();
secondThread.join();
편집
void Conversion::conversion(string _Part)
{
int value_Part = 1;
int valueShort = 0;
int value = checkValue;
if(value == value_Part)
{
// do stuff
}
}
과 같이
Conversion
인스턴스에 대한 포인터를 전달해야합니다. 'Conversion :: conversion'은 어떻게 생겼습니까? – juanchopanza@juanchopanza 전체 함수가 꽤 길지만, 그것이 어떻게 정의되고 시작되는지 더 자세히 알고 싶다면 – user1704863
'Conversion :: conversion'은 멤버 함수입니까? – juanchopanza