Remove TaskGraph::Drain which was only added initially for testing

The drain function was used only before the API gained the ability to
wait on the completion of a graph. This is the correct way to "drain"
the task executor of work.

Signed-off-by: Jeremy Ong <jcong@amazon.com>
This commit is contained in:
Jeremy Ong
2021-08-06 03:02:41 -06:00
parent 4743ca8bc1
commit 4f9c2cf693
3 changed files with 1 additions and 111 deletions
-89
View File
@@ -543,95 +543,6 @@ namespace UnitTest
EXPECT_EQ(3 | 0b100000, x);
}
TEST_F(TaskGraphTestFixture, ExecutorDrainRetained)
{
bool drainDone = false;
AZStd::binary_semaphore taskStart;
AZStd::binary_semaphore threadLaunched;
AZStd::binary_semaphore threadFinished;
TaskGraph graph;
auto a = graph.AddTask(
defaultTD,
[&]
{
taskStart.acquire();
});
graph.SubmitOnExecutor(*m_executor);
AZStd::thread drainThread{ [this, &drainDone, &threadLaunched, &threadFinished]
{
threadLaunched.release();
m_executor->Drain();
drainDone = true;
threadFinished.release();
} };
// Wait until our drain thread has launched
threadLaunched.acquire();
// The task itself hasn't started, so the drain should still be blocking
EXPECT_EQ(false, drainDone);
// Allow the task to finish
taskStart.release();
// Wait for the drain thread to wrap up
threadFinished.acquire();
// We successfully drained the executor
EXPECT_EQ(true, drainDone);
drainThread.join();
}
TEST_F(TaskGraphTestFixture, ExecutorDrainDetached)
{
bool drainDone = false;
AZStd::binary_semaphore taskStart;
AZStd::binary_semaphore threadLaunched;
AZStd::binary_semaphore threadFinished;
TaskGraph graph;
auto a = graph.AddTask(
defaultTD,
[&]
{
taskStart.acquire();
});
graph.Detach();
graph.SubmitOnExecutor(*m_executor);
AZStd::thread drainThread{ [this, &drainDone, &threadLaunched, &threadFinished]
{
threadLaunched.release();
m_executor->Drain();
drainDone = true;
threadFinished.release();
} };
// Wait until our drain thread has launched
threadLaunched.acquire();
// The task itself hasn't started, so the drain should still be blocking
EXPECT_EQ(false, drainDone);
// Allow the task to finish
taskStart.release();
// Wait for the drain thread to wrap up
threadFinished.acquire();
// We successfully drained the executor
EXPECT_EQ(true, drainDone);
drainThread.join();
}
} // namespace UnitTest
#if defined(HAVE_BENCHMARK)