Skip to content

Commit

Permalink
Fix occasionally-failing test in scheduling_operator_tests.cpp
Browse files Browse the repository at this point in the history
Disabled a CHECK() for the thread that the schedule_on() operator
resumes on since the outcome is actually not guaranteed with the
current implementation of task<T>. See #79 for details.
  • Loading branch information
lewissbaker committed Aug 8, 2018
1 parent 2d89231 commit 2115fee
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion test/scheduling_operator_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,17 @@ TEST_CASE_FIXTURE(io_service_fixture, "schedule_on task<> function")

co_await schedule_on(io_service(), start());

CHECK(std::this_thread::get_id() == ioThreadId);
// TODO: Uncomment this check once the implementation of task<T>
// guarantees that the continuation will resume on the same thread
// that the task completed on. Currently it's possible to resume on
// the thread that launched the task if it completes on another thread
// before the current thread could attach the continuation after it
// suspended. See cppcoro issue #79.
//
// The long-term solution here is to use the symmetric-transfer capability
// to avoid the use of atomics and races, but we're still waiting for MSVC to
// implement this (doesn't seem to be implemented as of VS 2017.8 Preview 5)
//CHECK(std::this_thread::get_id() == ioThreadId);
}());
}

Expand Down Expand Up @@ -111,6 +121,8 @@ TEST_CASE_FIXTURE(io_service_fixture, "resume_on task<> function")

co_await resume_on(io_service(), start());

// NOTE: This check could potentially spuriously fail with the current
// implementation of task<T>. See cppcoro issue #79.
CHECK(std::this_thread::get_id() != mainThreadId);
}());
}
Expand Down

0 comments on commit 2115fee

Please sign in to comment.