+ remove remaining boost::thread usage
+ don't link to boost_thread
This commit is contained in:
artemp 2013-10-11 14:18:35 +01:00
parent 582ca02f44
commit e231117504
3 changed files with 22 additions and 14 deletions

View file

@ -9,16 +9,22 @@
using namespace boost::chrono;
using namespace mapnik;
void threaded_benchmark(void test(),std::string const& name, unsigned threads) {
void threaded_benchmark(void test(),std::string const& name, unsigned num_threads) {
using namespace boost::chrono;
typedef process_cpu_clock clock_type;
process_real_cpu_clock::time_point start = process_real_cpu_clock::now();
boost::thread_group threads;
for (unsigned i=0;i<threads;++i)
//boost::thread_group threads;
typedef std::vector<std::unique_ptr<std::thread> > thread_group;
typedef thread_group::value_type value_type;
thread_group threads;
// create threads
for (unsigned i=0; i<num_threads; ++i)
{
threads.create_thread(test);
threads.emplace_back(new std::thread(test));
}
threads.join_all();
// join all
std::for_each(threads.begin(), threads.end(), [](value_type & t) {if (t->joinable()) t->join();});
clock_type::duration elapsed = process_real_cpu_clock::now() - start;
std::clog << boost::chrono::duration_cast<milliseconds>(elapsed)
<< " (" << boost::chrono::duration_cast<seconds>(elapsed) << ")"

View file

@ -13,17 +13,18 @@
#include <cstdio>
#include <set>
#include <stdexcept>
#include <thread>
#include <vector>
#include <memory>
// boost
#include <boost/version.hpp>
#include <memory>
#include <boost/make_shared.hpp>
#include <boost/bind.hpp>
#define BOOST_CHRONO_HEADER_ONLY
#include <boost/chrono/process_cpu_clocks.hpp>
#include <boost/chrono.hpp>
#include <boost/thread/thread.hpp>
//#include <boost/thread/thread.hpp>
using namespace boost::chrono;
using namespace mapnik;
@ -62,14 +63,15 @@ void benchmark(T & test_runner, std::string const& name)
dur elapsed;
if (test_runner.threads_ > 0)
{
boost::thread_group tg;
typedef std::vector<std::unique_ptr<std::thread> > thread_group;
typedef thread_group::value_type value_type;
thread_group tg;
for (unsigned i=0;i<test_runner.threads_;++i)
{
tg.create_thread(test_runner);
//tg.create_thread(boost::bind(&T::operator(),&test_runner));
tg.emplace_back(new std::thread(test_runner));
}
start = process_cpu_clock::now();
tg.join_all();
std::for_each(tg.begin(), tg.end(), [](value_type & t) {if (t->joinable()) t->join();});
elapsed = process_cpu_clock::now() - start;
}
else

View file

@ -86,8 +86,8 @@ if len(env['EXTRA_FREETYPE_LIBS']):
lib_env['LIBS'].append('xml2')
lib_env['LIBS'].append('z')
if env['THREADING'] == 'multi':
lib_env['LIBS'].append('boost_thread%s' % env['BOOST_APPEND'])
#if env['THREADING'] == 'multi':
# lib_env['LIBS'].append('boost_thread%s' % env['BOOST_APPEND'])
if '-DBOOST_REGEX_HAS_ICU' in env['CPPDEFINES']:
lib_env['LIBS'].append('icui18n')