Skip to content

Commit

Permalink
Fix allocator usage to compile with g++ 6.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskohlhoff committed Sep 10, 2016
1 parent 6cec69e commit 503b8bb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
8 changes: 6 additions & 2 deletions asio/src/examples/cpp11/executors/fork_join.cpp
Expand Up @@ -192,14 +192,18 @@ class fork_executor
template <class Func, class Alloc>
void dispatch(Func&& f, const Alloc& a) const
{
auto p(std::allocate_shared<function<Func>>(a, std::move(f), work_count_));
auto p(std::allocate_shared<function<Func>>(
typename std::allocator_traits<Alloc>::template rebind_alloc<char>(a),
std::move(f), work_count_));
context_.do_dispatch(p, work_count_);
}

template <class Func, class Alloc>
void post(Func f, const Alloc& a) const
{
auto p(std::allocate_shared<function<Func>>(a, std::move(f), work_count_));
auto p(std::allocate_shared<function<Func>>(
typename std::allocator_traits<Alloc>::template rebind_alloc<char>(a),
std::move(f), work_count_));
context_.do_post(p, work_count_);
}

Expand Down
5 changes: 4 additions & 1 deletion asio/src/examples/cpp11/executors/priority_scheduler.cpp
Expand Up @@ -47,7 +47,10 @@ class priority_scheduler : public execution_context
template <class Func, class Alloc>
void post(Func f, const Alloc& a) const
{
auto p(std::allocate_shared<item<Func>>(a, priority_, std::move(f)));
auto p(std::allocate_shared<item<Func>>(
typename std::allocator_traits<
Alloc>::template rebind_alloc<char>(a),
priority_, std::move(f)));
std::lock_guard<std::mutex> lock(context_.mutex_);
context_.queue_.push(p);
context_.condition_.notify_one();
Expand Down
8 changes: 6 additions & 2 deletions asio/src/examples/cpp14/executors/fork_join.cpp
Expand Up @@ -191,14 +191,18 @@ class fork_executor
template <class Func, class Alloc>
void dispatch(Func&& f, const Alloc& a) const
{
auto p(std::allocate_shared<function<Func>>(a, std::move(f), work_count_));
auto p(std::allocate_shared<function<Func>>(
typename std::allocator_traits<Alloc>::template rebind_alloc<char>(a),
std::move(f), work_count_));
context_.do_dispatch(p, work_count_);
}

template <class Func, class Alloc>
void post(Func f, const Alloc& a) const
{
auto p(std::allocate_shared<function<Func>>(a, std::move(f), work_count_));
auto p(std::allocate_shared<function<Func>>(
typename std::allocator_traits<Alloc>::template rebind_alloc<char>(a),
std::move(f), work_count_));
context_.do_post(p, work_count_);
}

Expand Down
5 changes: 4 additions & 1 deletion asio/src/examples/cpp14/executors/priority_scheduler.cpp
Expand Up @@ -46,7 +46,10 @@ class priority_scheduler : public execution_context
template <class Func, class Alloc>
void post(Func f, const Alloc& a) const
{
auto p(std::allocate_shared<item<Func>>(a, priority_, std::move(f)));
auto p(std::allocate_shared<item<Func>>(
typename std::allocator_traits<
Alloc>::template rebind_alloc<char>(a),
priority_, std::move(f)));
std::lock_guard<std::mutex> lock(context_.mutex_);
context_.queue_.push(p);
context_.condition_.notify_one();
Expand Down

0 comments on commit 503b8bb

Please sign in to comment.