Skip to content

Commit

Permalink
Move is_executor specializations to each Executor's own header
Browse files Browse the repository at this point in the history
  • Loading branch information
terranpro committed May 20, 2015
1 parent 8645b4f commit 08266b0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
25 changes: 0 additions & 25 deletions async-task/Async.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,31 +67,6 @@ struct async_result_invocation<void>
}
};

template<class Ex>
struct is_executor
: std::false_type
{};

template<>
struct is_executor<ThreadExecutor>
: std::true_type
{};

/// Dispatch a callback in the default thread context
template<class Func, class... Args, class = typename std::enable_if< !is_executor<Func>::value >::type >
auto async_impl(std::false_type, Func&& func, Args&&... args)
-> decltype( async_impl( std::true_type{},
ThreadExecutor::GetDefault(),
std::forward<Func>(func),
std::forward<Args>(args)... ) )
{
return async_impl( std::true_type{},
ThreadExecutor::GetDefault(),
std::forward<Func>(func),
std::forward<Args>(args)... );
}


template<class ArgTuple, class Enable = void>
struct invoker_impl;

Expand Down
10 changes: 10 additions & 0 deletions async-task/Executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ class Executor
void schedule(Handler&& handler);
};

template<class Ex>
struct is_executor
: std::false_type
{};

template<>
struct is_executor<Executor>
: std::true_type
{};

template<class Handler>
void Executor::schedule(Handler&& handler)
{
Expand Down
5 changes: 5 additions & 0 deletions async-task/GlibExecutor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ class GlibExecutor
}
};

template<>
struct is_executor<GlibExecutor>
: std::true_type
{};

} // namespace as

#endif // AS_GLIB_EXECUTOR_HPP
5 changes: 5 additions & 0 deletions async-task/ThreadExecutor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,11 @@ Executor& Executor::GetDefault()
return ex;
}

template<>
struct is_executor<ThreadExecutor>
: std::true_type
{};

} // namespace as

#endif // AS_THREAD_EXECUTOR_HPP

0 comments on commit 08266b0

Please sign in to comment.