diff options
author | Ulrich Germann <ugermann@inf.ed.ac.uk> | 2015-03-21 19:12:52 +0300 |
---|---|---|
committer | Ulrich Germann <ugermann@inf.ed.ac.uk> | 2015-03-21 19:12:52 +0300 |
commit | 8ca11d941d99df42664b32c101020283cc83054e (patch) | |
tree | eac36b128d9bfe22ff598458635ae66cdecbf57b /mert | |
parent | 85d2567b57af592a3a902209c7b0f3675576aac7 (diff) |
1. Lifetime of tasks in ThreadPool is now managed via shared pointers.
2. Code cleanup in IOWrapper and a bit elsewhere.
Diffstat (limited to 'mert')
-rw-r--r-- | mert/mert.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/mert/mert.cpp b/mert/mert.cpp index b73c536d1..275aa7b09 100644 --- a/mert/mert.cpp +++ b/mert/mert.cpp @@ -451,7 +451,7 @@ int main(int argc, char **argv) startingPoints.back().Randomize(); } - vector<vector<OptimizationTask*> > allTasks(1); + vector<vector<boost::shared_ptr<OptimizationTask> > > allTasks(1); //optional sharding vector<Data> shards; @@ -466,13 +466,14 @@ int main(int argc, char **argv) if (option.shard_count) data_ref = shards[i]; //use the sharded data if it exists - vector<OptimizationTask*>& tasks = allTasks[i]; + vector<boost::shared_ptr<OptimizationTask> >& tasks = allTasks[i]; Optimizer *optimizer = OptimizerFactory::BuildOptimizer(option.pdim, to_optimize, positive, start_list[0], option.optimize_type, option.nrandom); optimizer->SetScorer(data_ref.getScorer()); optimizer->SetFeatureData(data_ref.getFeatureData()); // A task for each start point for (size_t j = 0; j < startingPoints.size(); ++j) { - OptimizationTask* task = new OptimizationTask(optimizer, startingPoints[j]); + boost::shared_ptr<OptimizationTask> + task(new OptimizationTask(optimizer, startingPoints[j])); tasks.push_back(task); #ifdef WITH_THREADS pool.Submit(task); @@ -538,9 +539,6 @@ int main(int argc, char **argv) for (size_t i = 0; i < allTasks.size(); ++i) { allTasks[i][0]->resetOptimizer(); - for (size_t j = 0; j < allTasks[i].size(); ++j) { - delete allTasks[i][j]; - } } PrintUserTime("Stopping..."); |