Skip to content

Commit

Permalink
io_service_pool::work is adapted to old libstdc++ behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonBikineev committed Jul 28, 2015
1 parent b8e08bc commit d305747
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
18 changes: 17 additions & 1 deletion hpx/util/io_service_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@ namespace hpx { namespace util

private:
typedef std::unique_ptr<boost::asio::io_service> io_service_ptr;
#if (defined(HPX_GCC_VERSION) && HPX_GCC_VERSION < 40700)
typedef std::unique_ptr<boost::asio::io_service::work> work_type;
#else
typedef boost::asio::io_service::work work_type;
#endif

BOOST_FORCEINLINE work_type initialize_work(boost::asio::io_service& io_service)
{
return work_type(
#if (defined(HPX_GCC_VERSION) && HPX_GCC_VERSION < 40700)
new boost::asio::io_service::work(io_service)
#else
io_service
#endif
);
}

boost::mutex mtx_;

Expand All @@ -98,7 +114,7 @@ namespace hpx { namespace util
std::vector<boost::thread> threads_;

/// The work that keeps the io_services running.
std::vector<boost::asio::io_service::work> work_;
std::vector<work_type> work_;

/// The next io_service to use for a connection.
std::size_t next_io_service_;
Expand Down
6 changes: 3 additions & 3 deletions src/util/io_service_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace hpx { namespace util
for (std::size_t i = 0; i < pool_size; ++i)
{
io_services_.emplace_back(new boost::asio::io_service);
work_.emplace_back(boost::asio::io_service::work(*io_services_[i]));
work_.emplace_back(initialize_work(*io_services_[i]));
}
}

Expand All @@ -60,7 +60,7 @@ namespace hpx { namespace util
for (std::size_t i = 0; i < pool_size_; ++i)
{
io_services_.emplace_back(new boost::asio::io_service);
work_.emplace_back(boost::asio::io_service::work(*io_services_[i]));
work_.emplace_back(initialize_work(*io_services_[i]));
}
}

Expand Down Expand Up @@ -111,7 +111,7 @@ namespace hpx { namespace util
for (std::size_t i = 0; i < pool_size_; ++i)
{
io_services_.emplace_back(new boost::asio::io_service);
work_.emplace_back(boost::asio::io_service::work(*io_services_[i]));
work_.emplace_back(initialize_work(*io_services_[i]));
}
}

Expand Down

0 comments on commit d305747

Please sign in to comment.