| 71 | } |
| 72 | |
| 73 | TEST(ObjectCache, release_cycle) { |
| 74 | set_log_output_level(ALOG_INFO); |
| 75 | DEFER(set_log_output_level(ALOG_DEBUG)); |
| 76 | ObjectCache<int, ShowOnDtor*> ocache(1000UL * 1000 * 10); |
| 77 | // 10s, during the test, nothing will be free if not set recycle |
| 78 | std::vector<photon::join_handle*> handles; |
| 79 | std::vector<OCArg> args; |
| 80 | cycle_cnt = 0; |
| 81 | release_cnt = 0; |
| 82 | for (int i = 0; i < 100; i++) { |
| 83 | args.emplace_back(OCArg({&ocache, i + 1})); |
| 84 | } |
| 85 | for (auto& arg : args) { |
| 86 | handles.emplace_back( |
| 87 | photon::thread_enable_join(photon::thread_create(&objcache, &arg))); |
| 88 | } |
| 89 | for (const auto& handle : handles) { |
| 90 | photon::thread_join(handle); |
| 91 | } |
| 92 | EXPECT_EQ(cycle_cnt, release_cnt); |
| 93 | } |
| 94 | |
| 95 | TEST(ObjectCache, timeout_refresh) { |
| 96 | release_cnt = 0; |
nothing calls this directly
no test coverage detected