Multi-threaded execution of the TestRandomInternalImpl.
| 2111 | |
| 2112 | // Multi-threaded execution of the TestRandomInternalImpl. |
| 2113 | void BufferPoolTest::TestRandomInternalMulti( |
| 2114 | int num_threads, int64_t min_buffer_len, bool multiple_pins) { |
| 2115 | const int MAX_NUM_BUFFERS_PER_THREAD = 200; |
| 2116 | const int64_t TOTAL_MEM = num_threads * MAX_NUM_BUFFERS_PER_THREAD * min_buffer_len; |
| 2117 | MetricGroup tmp_metrics("test-metrics"); |
| 2118 | BufferPool pool(&tmp_metrics, min_buffer_len, TOTAL_MEM, TOTAL_MEM); |
| 2119 | global_reservations_.InitRootTracker(NewProfile(), TOTAL_MEM); |
| 2120 | MemTracker global_tracker(TOTAL_MEM); |
| 2121 | TmpFileGroup* shared_file_group = NewFileGroup(); |
| 2122 | thread_group workers; |
| 2123 | vector<mt19937> rngs = RandTestUtil::CreateThreadLocalRngs(num_threads, &rng_); |
| 2124 | for (int i = 0; i < num_threads; ++i) { |
| 2125 | workers.add_thread(new thread( |
| 2126 | [this, &pool, shared_file_group, &global_tracker, &rngs, i, multiple_pins]() { |
| 2127 | TestRandomInternalImpl( |
| 2128 | &pool, shared_file_group, &global_tracker, &rngs[i], i, multiple_pins); |
| 2129 | })); |
| 2130 | } |
| 2131 | |
| 2132 | AtomicInt32 stop_maintenance(0); |
| 2133 | thread maintenance_thread([&pool, &stop_maintenance]() { |
| 2134 | while (stop_maintenance.Load() == 0) { |
| 2135 | pool.Maintenance(); |
| 2136 | SleepForMs(50); |
| 2137 | } |
| 2138 | }); |
| 2139 | workers.join_all(); |
| 2140 | stop_maintenance.Add(1); |
| 2141 | maintenance_thread.join(); |
| 2142 | global_reservations_.Close(); |
| 2143 | } |
| 2144 | |
| 2145 | /// Randomly issue AllocateBuffer(), FreeBuffer(), CreatePage(), Pin(), Unpin(), and |
| 2146 | /// DestroyPage() calls. All calls made are legal - error conditions are not expected. |
nothing calls this directly
no test coverage detected