Return Double from Boost thread
- by Benedikt Wutzi
Hi I have an Boost thread which should return a double. The function looks like this:
void analyser::findup(const double startwl, const double max, double &myret){
  this->data.begin();
  for(int i = (int)data.size() ; i >= 0;i--){
    if(this->data[i].lambda > startwl){
      if(this->data[i].db >= (max-30)) {
        myret = this->data[i+1].lambda;
        std::cout <<"in thread " << myret << std::endl;
        return;
      }
    }
  }
}
this function is called by another function:
void analyser::start_find_up(const double startwl, const double max){
  double tmp = -42.0;
  boost::thread up(&analyser::findup,*this, startwl,max,tmp);
  std::cout << "before join " << tmp << std::endl;
  up.join();
  std::cout << "after join " << tmp << std::endl;
}
Anyway I've tried and googled almost anything but i can't get it to return a value.
The output looks like this right now.
before join -42
in thread 843.487
after join -42
Thanks for any help.