Skip to content

Commit

Permalink
fix asan pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
oathdruid committed Sep 19, 2024
1 parent 84c352b commit d87478c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/babylon/executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ class Executor {
// that coroutine, and can be used to wait and get the co_return value just
// like use co_await inside another coroutine.
template <typename F = SchedInterface, typename C, typename... Args>
//#if __cpp_concepts && __cpp_lib_coroutine
requires ((::std::is_invocable<C&&, Args&&...>::value) &&
(!CoroutineInvocable<C &&, Args && ...>))
//#endif // __cpp_concepts && __cpp_lib_coroutine
#if __cpp_concepts && __cpp_lib_coroutine
requires (::std::is_invocable<C&&, Args&&...>::value &&
!CoroutineInvocable<C &&, Args && ...>)
#endif // __cpp_concepts && __cpp_lib_coroutine
inline Future<ResultType<C&&, Args&&...>, F> execute(C&& callable,
Args&&... args) noexcept;
#if __cpp_concepts && __cpp_lib_coroutine
Expand Down
15 changes: 11 additions & 4 deletions src/babylon/executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ inline Executor::CoroutineHandle::CoroutineHandle(
////////////////////////////////////////////////////////////////////////////////
// Executor begin
template <typename F, typename C, typename... Args>
//#if __cpp_concepts && __cpp_lib_coroutine
requires ((::std::is_invocable<C&&, Args&&...>::value) &&
(!CoroutineInvocable<C &&, Args && ...>))
//#endif // __cpp_concepts && __cpp_lib_coroutine
#if __cpp_concepts && __cpp_lib_coroutine
requires (::std::is_invocable<C&&, Args&&...>::value &&
!CoroutineInvocable<C &&, Args && ...>)
#endif // __cpp_concepts && __cpp_lib_coroutine
inline Future<Executor::ResultType<C&&, Args&&...>, F> Executor::execute(
C&& callable, Args&&... args) noexcept {
using R = ResultType<C&&, Args&&...>;
Expand Down Expand Up @@ -58,8 +58,15 @@ template <typename F, typename C, typename... Args>
requires CoroutineInvocable<C&&, Args&&...> && Executor::IsPlainFunction<C>
inline Future<Executor::ResultType<C&&, Args&&...>, F> Executor::execute(
C&& callable, Args&&... args) noexcept {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wunknown-warning-option"
#if ABSL_HAVE_ADDRESS_SANITIZER
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif // ABSL_HAVE_ADDRESS_SANITIZER
auto task =
::std::invoke(::std::forward<C>(callable), ::std::forward<Args>(args)...);
#pragma GCC diagnostic pop
return execute<F>(::std::move(task));
}

Expand Down
8 changes: 8 additions & 0 deletions test/test_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,15 @@ TEST_F(ExecutorTest, current_executor_mark_during_execution) {
{
struct S {
static void function(Executor& e) {
(void) e;
ASSERT_EQ(&e, ::babylon::CurrentExecutor::get());
}
void member_function(Executor& e) {
(void) e;
ASSERT_EQ(&e, ::babylon::CurrentExecutor::get());
}
void operator()(Executor& e) {
(void) e;
ASSERT_EQ(&e, ::babylon::CurrentExecutor::get());
}
} s;
Expand All @@ -402,6 +405,7 @@ TEST_F(ExecutorTest, current_executor_mark_during_execution) {
thread_executor
.execute(
[](Executor& e) {
(void) e;
ASSERT_EQ(&e, ::babylon::CurrentExecutor::get());
},
::std::ref(thread_executor))
Expand All @@ -410,14 +414,17 @@ TEST_F(ExecutorTest, current_executor_mark_during_execution) {
{
struct S {
static ::babylon::CoroutineTask<> run(Executor& e) {
(void) e;
assert(&e == ::babylon::CurrentExecutor::get());
co_return;
}
::babylon::CoroutineTask<> member_run(Executor& e) {
(void) e;
assert(&e == ::babylon::CurrentExecutor::get());
co_return;
}
::babylon::CoroutineTask<> operator()(Executor& e) {
(void) e;
assert(&e == ::babylon::CurrentExecutor::get());
co_return;
}
Expand All @@ -428,6 +435,7 @@ TEST_F(ExecutorTest, current_executor_mark_during_execution) {
thread_executor
.execute(
[&](Executor& e) -> CoroutineTask<> {
(void) e;
assert(&e == ::babylon::CurrentExecutor::get());
co_return;
},
Expand Down

0 comments on commit d87478c

Please sign in to comment.