FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Use 'requires' keyword to support C++20 features by yumeno-yan · Pull Request #666 · taskflow/taskflow · GitHub

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .hpp  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
40 changes: 40 additions & 0 deletions taskflow/core/async.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,29 @@ inline void Executor::_tear_down_async(Worker& worker, Node* node, Node*& cache)
// ----------------------------------------------------------------------------

// Function: silent_dependent_async
#if __cplusplus >= TF_CPP20
template <typename F, typename... Tasks>
requires all_same_v<AsyncTask, std::decay_t<Tasks>...>
#else
template <typename F, typename... Tasks,
std::enable_if_t<all_same_v<AsyncTask, std::decay_t<Tasks>...>, void>*
>
#endif
tf::AsyncTask Executor::silent_dependent_async(F&& func, Tasks&&... tasks) {
return silent_dependent_async(
DefaultTaskParams{}, std::forward<F>(func), std::forward<Tasks>(tasks)...
);
}

// Function: silent_dependent_async
#if __cplusplus >= TF_CPP20
template <typename P, typename F, typename... Tasks>
requires is_task_params_v<P> && all_same_v<AsyncTask, std::decay_t<Tasks>...>
#else
template <typename P, typename F, typename... Tasks,
std::enable_if_t<is_task_params_v<P> && all_same_v<AsyncTask, std::decay_t<Tasks>...>, void>*
>
#endif
tf::AsyncTask Executor::silent_dependent_async(
P&& params, F&& func, Tasks&&... tasks
){
Expand All @@ -101,17 +111,27 @@ tf::AsyncTask Executor::silent_dependent_async(
}

// Function: silent_dependent_async
#if __cplusplus >= TF_CPP20
template <typename F, typename I>
requires (!std::is_same_v<std::decay_t<I>, AsyncTask>)
#else
template <typename F, typename I,
std::enable_if_t<!std::is_same_v<std::decay_t<I>, AsyncTask>, void>*
>
#endif
tf::AsyncTask Executor::silent_dependent_async(F&& func, I first, I last) {
return silent_dependent_async(DefaultTaskParams{}, std::forward<F>(func), first, last);
}

// Function: silent_dependent_async
#if __cplusplus >= TF_CPP20
template <typename P, typename F, typename I>
requires (is_task_params_v<P> && !std::is_same_v<std::decay_t<I>, AsyncTask>)
#else
template <typename P, typename F, typename I,
std::enable_if_t<is_task_params_v<P> && !std::is_same_v<std::decay_t<I>, AsyncTask>, void>*
>
#endif
tf::AsyncTask Executor::silent_dependent_async(
P&& params, F&& func, I first, I last
) {
Expand Down Expand Up @@ -141,17 +161,27 @@ tf::AsyncTask Executor::silent_dependent_async(
// ----------------------------------------------------------------------------

// Function: dependent_async
#if __cplusplus >= TF_CPP20
template <typename F, typename... Tasks>
requires all_same_v<AsyncTask, std::decay_t<Tasks>...>
#else
template <typename F, typename... Tasks,
std::enable_if_t<all_same_v<AsyncTask, std::decay_t<Tasks>...>, void>*
>
#endif
auto Executor::dependent_async(F&& func, Tasks&&... tasks) {
return dependent_async(DefaultTaskParams{}, std::forward<F>(func), std::forward<Tasks>(tasks)...);
}

// Function: dependent_async
#if __cplusplus >= TF_CPP20
template <typename P, typename F, typename... Tasks>
requires is_task_params_v<P> && all_same_v<AsyncTask, std::decay_t<Tasks>...>
#else
template <typename P, typename F, typename... Tasks,
std::enable_if_t<is_task_params_v<P> && all_same_v<AsyncTask, std::decay_t<Tasks>...>, void>*
>
#endif
auto Executor::dependent_async(P&& params, F&& func, Tasks&&... tasks) {
std::array<AsyncTask, sizeof...(Tasks)> array = { std::forward<Tasks>(tasks)... };
return dependent_async(
Expand All @@ -160,17 +190,27 @@ auto Executor::dependent_async(P&& params, F&& func, Tasks&&... tasks) {
}

// Function: dependent_async
#if __cplusplus >= TF_CPP20
template <typename F, typename I>
requires (!std::is_same_v<std::decay_t<I>, AsyncTask>)
#else
template <typename F, typename I,
std::enable_if_t<!std::is_same_v<std::decay_t<I>, AsyncTask>, void>*
>
#endif
auto Executor::dependent_async(F&& func, I first, I last) {
return dependent_async(DefaultTaskParams{}, std::forward<F>(func), first, last);
}

// Function: dependent_async
#if __cplusplus >= TF_CPP20
template <typename P, typename F, typename I>
requires (is_task_params_v<P> && !std::is_same_v<std::decay_t<I>, AsyncTask>)
#else
template <typename P, typename F, typename I,
std::enable_if_t<is_task_params_v<P> && !std::is_same_v<std::decay_t<I>, AsyncTask>, void>*
>
#endif
auto Executor::dependent_async(P&& params, F&& func, I first, I last) {

_increment_topology();
Expand Down
45 changes: 43 additions & 2 deletions taskflow/core/executor.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -738,9 +738,15 @@ class Executor {

This member function is thread-safe.
*/

#if __cplusplus >= TF_CPP20
template <typename F, typename... Tasks>
requires all_same_v<AsyncTask, std::decay_t<Tasks>...>
#else
template <typename F, typename... Tasks,
std::enable_if_t<all_same_v<AsyncTask, std::decay_t<Tasks>...>, void>* = nullptr
>
#endif
tf::AsyncTask silent_dependent_async(F&& func, Tasks&&... tasks);

/**
Expand Down Expand Up @@ -774,9 +780,14 @@ class Executor {

This member function is thread-safe.
*/
#if __cplusplus >= TF_CPP20
template <typename P, typename F, typename... Tasks>
requires is_task_params_v<P> && all_same_v<AsyncTask, std::decay_t<Tasks>...>
#else
template <typename P, typename F, typename... Tasks,
std::enable_if_t<is_task_params_v<P> && all_same_v<AsyncTask, std::decay_t<Tasks>...>, void>* = nullptr
>
#endif
tf::AsyncTask silent_dependent_async(P&& params, F&& func, Tasks&&... tasks);

/**
Expand Down Expand Up @@ -811,9 +822,14 @@ class Executor {

This member function is thread-safe.
*/
template <typename F, typename I,
#if __cplusplus >= TF_CPP20
template <typename F, typename I>
requires (!std::is_same_v<std::decay_t<I>, AsyncTask>)
#else
template <typename F, typename I,
std::enable_if_t<!std::is_same_v<std::decay_t<I>, AsyncTask>, void>* = nullptr
>
#endif
tf::AsyncTask silent_dependent_async(F&& func, I first, I last);

/**
Expand Down Expand Up @@ -850,9 +866,14 @@ class Executor {

This member function is thread-safe.
*/
template <typename P, typename F, typename I,
#if __cplusplus >= TF_CPP20
template <typename P, typename F, typename I>
requires (is_task_params_v<P> && !std::is_same_v<std::decay_t<I>, AsyncTask>)
#else
template <typename P, typename F, typename I,
std::enable_if_t<is_task_params_v<P> && !std::is_same_v<std::decay_t<I>, AsyncTask>, void>* = nullptr
>
#endif
tf::AsyncTask silent_dependent_async(P&& params, F&& func, I first, I last);

// --------------------------------------------------------------------------
Expand Down Expand Up @@ -896,9 +917,14 @@ class Executor {

This member function is thread-safe.
*/
#if __cplusplus >= TF_CPP20
template <typename F, typename... Tasks>
requires all_same_v<AsyncTask, std::decay_t<Tasks>...>
#else
template <typename F, typename... Tasks,
std::enable_if_t<all_same_v<AsyncTask, std::decay_t<Tasks>...>, void>* = nullptr
>
#endif
auto dependent_async(F&& func, Tasks&&... tasks);

/**
Expand Down Expand Up @@ -942,9 +968,14 @@ class Executor {

This member function is thread-safe.
*/
#if __cplusplus >= TF_CPP20
template <typename P, typename F, typename... Tasks>
requires is_task_params_v<P> && all_same_v<AsyncTask, std::decay_t<Tasks>...>
#else
template <typename P, typename F, typename... Tasks,
std::enable_if_t<is_task_params_v<P> && all_same_v<AsyncTask, std::decay_t<Tasks>...>, void>* = nullptr
>
#endif
auto dependent_async(P&& params, F&& func, Tasks&&... tasks);

/**
Expand Down Expand Up @@ -987,9 +1018,14 @@ class Executor {

This member function is thread-safe.
*/
#if __cplusplus >= TF_CPP20
template <typename F, typename I>
requires (!std::is_same_v<std::decay_t<I>, AsyncTask>)
#else
template <typename F, typename I,
std::enable_if_t<!std::is_same_v<std::decay_t<I>, AsyncTask>, void>* = nullptr
>
#endif
auto dependent_async(F&& func, I first, I last);

/**
Expand Down Expand Up @@ -1036,9 +1072,14 @@ class Executor {

This member function is thread-safe.
*/
#if __cplusplus >= TF_CPP20
template <typename P, typename F, typename I>
requires (is_task_params_v<P> && !std::is_same_v<std::decay_t<I>, AsyncTask>)
#else
template <typename P, typename F, typename I,
std::enable_if_t<is_task_params_v<P> && !std::is_same_v<std::decay_t<I>, AsyncTask>, void>* = nullptr
>
#endif
auto dependent_async(P&& params, F&& func, I first, I last);

private:
Expand Down

Back | FazBrowse Home | New Git URL