mirror of
				https://github.com/boostorg/unordered.git
				synced 2025-11-04 01:31:41 +01:00 
			
		
		
		
	Update test to spin until the container is non-empty
This commit is contained in:
		@@ -534,22 +534,25 @@ namespace {
 | 
			
		||||
    {
 | 
			
		||||
      map_type x(0, hasher(1), key_equal(2), allocator_type{});
 | 
			
		||||
 | 
			
		||||
      auto f = [&x, &values, &m, &cv, &ready] {
 | 
			
		||||
      std::atomic_uint num_transfers{0};
 | 
			
		||||
 | 
			
		||||
      std::thread t1([&x, &values] {
 | 
			
		||||
        for (auto const& val : values) {
 | 
			
		||||
          x.insert(val);
 | 
			
		||||
        }
 | 
			
		||||
      });
 | 
			
		||||
 | 
			
		||||
      std::thread t2([&x, &m, &cv, &ready] {
 | 
			
		||||
        while (x.empty()) {
 | 
			
		||||
          std::this_thread::yield();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        {
 | 
			
		||||
          std::lock_guard<std::mutex> guard(m);
 | 
			
		||||
          ready = true;
 | 
			
		||||
        }
 | 
			
		||||
        cv.notify_all();
 | 
			
		||||
 | 
			
		||||
        for (auto const& val : values) {
 | 
			
		||||
          x.insert(val);
 | 
			
		||||
        }
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
      std::atomic_uint num_transfers{0};
 | 
			
		||||
 | 
			
		||||
      std::thread t1(f);
 | 
			
		||||
      std::thread t2(f);
 | 
			
		||||
      });
 | 
			
		||||
 | 
			
		||||
      thread_runner(
 | 
			
		||||
        values, [&x, &reference_map, &num_transfers, rg, &m, &ready, &cv](
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user