+bool ThreadGeneSorter::running(){
+ return !_done;
+}
+
+double ThreadGeneSorter::wait(time_t time, size_t solutions){
+
+ timeval now;
+ gettimeofday(&now, NULL);
+ timespec timeout;
+ timeout.tv_sec = now.tv_sec + time;
+ timeout.tv_nsec = 0;
+
+ int err = 0;
+
+ Mutex m(&_solutionslock);
+ size_t n = _solutions.size();
+
+ while (!_done && err != ETIMEDOUT
+ && _solutions.size() - n < solutions){
+ err = pthread_cond_timedwait(&_addedSolution,&_solutionslock
+ , &timeout);
+ }
+ if (_solutions.size() == 0)
+ return 0.0;
+ return _solutions.top().first;