message: Don't use NoPageReclaimGovernor after destruction in unit tests
  Fixes
diff: @@ -64,6 +64,7 @@ using namespace realm::util;
  #include <realm/util/encrypted_file_mapping.hpp>
  #include <realm/util/to_string.hpp>
  +#include <realm/util/scope_exit.hpp>
  #include <future>
  #include <chrono>
  @@ -1014,12 +1015,16 @@ NONCONCURRENT_TEST(Metrics_NumDecryptedPagesWithoutEncryption)
  auto tr = sg->start_write();
  tr->add_table("table");
  +#if REALM_ENABLE_ENCRYPTION
  // we need this here because other unit tests might be using encryption and we need a guarantee
  // that the global pages are from this shared group only.
  NoPageReclaimGovernor gov;
  realm::util::set_page_reclaim_governor(&gov);
  + // the remainder of the test suite should use the default.
  + auto on_exit = make_scope_exit([]() noexcept { realm::util::set_page_reclaim_governor_to_default(); });
  CHECK(gov.has_run_twice.valid());
  - gov.has_run_twice.wait_for(std::chrono::seconds(2));
  + REALM_ASSERT_RELEASE(gov.has_run_twice.wait_for(std::chrono::seconds(30)) == std::future_status::ready);
  +#endif
  tr->commit();
  }
  @@ -1041,8 +1046,6 @@ NONCONCURRENT_TEST(Metrics_NumDecryptedPagesWithoutEncryption)
  CHECK_EQUAL(transactions->at(1).get_transaction_type(),
  realm::metrics::TransactionInfo::TransactionType::read_transaction);
  CHECK_EQUAL(transactions->at(1).get_num_decrypted_pages(), 0);
  -
  - realm::util::set_page_reclaim_governor_to_default(); // the remainder of the test suite should use the default
  }
  // this test relies on the global state of the number of decrypted pages and therefore must be run in isolation
  @@ -1059,10 +1062,14 @@ NONCONCURRENT_TEST_IF(Metrics_NumDecryptedPagesWithEncryption, REALM_ENABLE_ENCR
  auto tr = sg->start_write();
  tr->add_table("table");
  +#if REALM_ENABLE_ENCRYPTION
  NoPageReclaimGovernor gov;
  realm::util::set_page_reclaim_governor(&gov);
  + // the remainder of the test suite should use the default.
  + auto on_exit = make_scope_exit([]() noexcept { realm::util::set_page_reclaim_governor_to_default(); });
  CHECK(gov.has_run_twice.valid());
  - gov.has_run_twice.wait_for(std::chrono::seconds(2));
  + REALM_ASSERT_RELEASE(gov.has_run_twice.wait_for(std::chrono::seconds(30)) == std::future_status::ready);
  +#endif
  tr->commit();
  }
  @@ -1084,8 +1091,6 @@ NONCONCURRENT_TEST_IF(Metrics_NumDecryptedPagesWithEncryption, REALM_ENABLE_ENCR
  CHECK_EQUAL(transactions->at(1).get_transaction_type(),
  realm::metrics::TransactionInfo::TransactionType::read_transaction);
  CHECK_EQUAL(transactions->at(1).get_num_decrypted_pages(), 1);
  -
  - realm::util::set_page_reclaim_governor_to_default(); // the remainder of the test suite should use the default
  }
  TEST(Metrics_MemoryChecks)
  