[threading linux] Implement suspendable pthreads
Use real-time event interrupt to communicate suspend in timely manner. Use conditional_variable to implement suspend wait and resume trigger. Ignore real-time event 36 in .gdbinit which is used to signal suspend. Test suspending threads.
This commit is contained in:
committed by
Rick Gibbed
parent
b2912e7891
commit
4397f25325
@@ -759,8 +759,29 @@ TEST_CASE("Create and Run Thread", "Thread") {
|
||||
}
|
||||
|
||||
TEST_CASE("Test Suspending Thread", "Thread") {
|
||||
// TODO(bwrsandman): Test suspension and resume
|
||||
REQUIRE(true);
|
||||
std::unique_ptr<Thread> thread;
|
||||
WaitResult result;
|
||||
Thread::CreationParameters params = {};
|
||||
auto func = [] { Sleep(20ms); };
|
||||
|
||||
// Create initially suspended
|
||||
params.create_suspended = true;
|
||||
thread = threading::Thread::Create(params, func);
|
||||
result = threading::Wait(thread.get(), false, 50ms);
|
||||
REQUIRE(result == threading::WaitResult::kTimeout);
|
||||
thread->Resume();
|
||||
result = threading::Wait(thread.get(), false, 50ms);
|
||||
REQUIRE(result == threading::WaitResult::kSuccess);
|
||||
params.create_suspended = false;
|
||||
|
||||
// Create and then suspend
|
||||
thread = threading::Thread::Create(params, func);
|
||||
thread->Suspend();
|
||||
result = threading::Wait(thread.get(), false, 50ms);
|
||||
REQUIRE(result == threading::WaitResult::kTimeout);
|
||||
thread->Resume();
|
||||
result = threading::Wait(thread.get(), false, 50ms);
|
||||
REQUIRE(result == threading::WaitResult::kSuccess);
|
||||
}
|
||||
|
||||
TEST_CASE("Test Thread QueueUserCallback", "Thread") {
|
||||
|
||||
Reference in New Issue
Block a user