feat/support_fiber #6

Merged
tqcq merged 52 commits from feat/support_fiber into master 2024-08-11 13:03:04 +08:00
Showing only changes of commit 7b13e5584a - Show all commits

View File

@ -36,8 +36,8 @@ class CondVarTest : public ::testing::Test {
protected:
Mutex *m;
CondVar *cv;
volatile bool is_set;
volatile bool is_timeout;
bool is_set;
bool is_timeout;
std::thread *worker;
};
@ -69,6 +69,7 @@ TEST_F(CondVarTest, NotifyOne_Wait) {
TEST_F(CondVarTest, NotifyOne_WaitFor) {
// Wait
// constexpr auto kWaitTimeoutMs = 100;
auto start = ReadSteadyClock();
constexpr auto kWaitTimeout = std::chrono::milliseconds(50);
auto WaitFor = [&] {
UniqueLock<Mutex> inner_locker(*m);
@ -91,9 +92,16 @@ TEST_F(CondVarTest, NotifyOne_WaitFor) {
cv->NotifyOne();
}
auto now = ReadSteadyClock();
t1.join();
ASSERT_TRUE(is_set);
ASSERT_FALSE(is_timeout);
if (now - start > kWaitTimeout) {
// timeout
ASSERT_TRUE(is_timeout);
ASSERT_FALSE(is_set);
} else {
ASSERT_FALSE(is_timeout);
ASSERT_TRUE(is_set);
}
}
// timeout