Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Launch #171

Closed
2 tasks done
4kangjc opened this issue Oct 28, 2022 · 0 comments
Closed
2 tasks done

Refactor Launch #171

4kangjc opened this issue Oct 28, 2022 · 0 comments

Comments

@4kangjc
Copy link
Collaborator

4kangjc commented Oct 28, 2022

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

在不改变函数调用形式的情况下,重构Launch,增强可读性,美观

// before
struct Launch {
    struct Prompt {};
    struct Schedule {};
    struct Current {};
};
// after
enum class Launch {
    Prompt,
    Schedule,
    Current,
};
// before
template <class T, class F,
          typename std::enable_if<std::is_same<T, Launch::Prompt>::value,
                                  T>::type* = nullptr>
inline Uthread async(F&& f, Executor* ex) {
    ...
}

template <class T, class F,
          typename std::enable_if<std::is_same<T, Launch::Schedule>::value,
                                  T>::type* = nullptr>
inline void async(F&& f, Executor* ex) {
    ...
}

// after
template <Launch T, class F>
inline std::enable_if_t<T == Launch::Prompt, Uthread> async(F&& f, Executor* ex) {
    ...
}

template <Launch T, class F>
inline std::enable_if_t<T == Launch::Schedule> async(F&& f, Executor* ex) {
   ...
}

Reproduction way

Anything else

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!
@4kangjc 4kangjc changed the title refactor Launch Refactor Launch Oct 28, 2022
@4kangjc 4kangjc closed this as completed Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant