feat/support_fiber #2

Merged
tqcq merged 57 commits from feat/support_fiber into master 2024-06-21 10:33:52 +08:00
Showing only changes of commit 2a09d4cef7 - Show all commits

View File

@ -7,7 +7,7 @@ namespace fiber {
namespace detail { namespace detail {
TEST(Fiber, Base) { TEST(Fiber, Base) {
constexpr auto kMaxCnt = 5000; constexpr auto kMaxCnt = 5000000;
int cnt = 0; int cnt = 0;
// 0 -> master fiber // 0 -> master fiber
@ -24,16 +24,14 @@ TEST(Fiber, Base) {
ASSERT_EQ(Fiber::Current(), fibers[i].get()); ASSERT_EQ(Fiber::Current(), fibers[i].get());
++cnt; ++cnt;
Fiber::MasterFiber()->Resume(); Fiber::MasterFiber()->Resume();
TILE_LOG_INFO("worke cnt: {}", cnt);
} }
})); }));
} }
while (cnt < kMaxCnt) { while (cnt < kMaxCnt) {
int old = cnt; int old = cnt;
auto next_fiber = fibers[Random(1, 1)].get(); auto next_fiber = fibers[Random(1, 9)].get();
TILE_LOG_INFO("cnt: {}", cnt);
next_fiber->Resume(); next_fiber->Resume();
ASSERT_EQ(old + 1, cnt); ASSERT_EQ(old + 1, cnt);
ASSERT_EQ(Fiber::Current(), Fiber::MasterFiber()); ASSERT_EQ(Fiber::Current(), Fiber::MasterFiber());