tensorflow/core/common_runtime/device/device_event_mgr_test.cc
// Tests that WarnIfInCallback() triggers correctly.
Tests that WarnIfInCallback() triggers correctly.
Tests that WarnIfInCallback () triggers correctly .
TEST(EventMgr, WarnIfInCallback) {
  auto stream_exec = GPUMachineManager()->ExecutorForDevice(0).ValueOrDie();
  TEST_EventMgr em(stream_exec, GPUOptions());
  TEST_EventMgrHelper th(&em);
  std::unique_ptr<se::Stream> stream(new se::Stream(stream_exec));
  CHECK(stream);
  stream->Init();
  bool hit = false;
  th.StartPollingLoop();
  device_event_mgr::WarnIfInCallback([&hit] { hit = true; });
  EXPECT_FALSE(hit);
  Notification note;
  em.ThenExecute(stream.get(), [&hit, &note]() {
    device_event_mgr::WarnIfInCallback([&hit, &note] {
      hit = true;
      note.Notify();
    });
  });
  note.WaitForNotification();
  EXPECT_TRUE(hit);
}
TEST ( EventMgr , WarnIfInCallback ) { auto stream_exec = GPUMachineManager ( ) -> ExecutorForDevice ( 0 ) . ValueOrDie ( ) ; TEST_EventMgr em ( stream_exec , GPUOptions ( ) ) ; TEST_EventMgrHelper th ( & em ) ; std :: unique_ptr < se :: Stream > stream ( new se :: Stream ( stream_exec ) ) ; CHECK ( stream ) ; stream -> Init ( ) ; bool hit = false ; th . StartPollingLoop ( ) ; device_event_mgr :: WarnIfInCallback ( [ & hit ] { hit = true ; } ) ; EXPECT_FALSE ( hit ) ; Notification note ; em . ThenExecute ( stream . get ( ) , [ & hit , & note ] ( ) { device_event_mgr :: WarnIfInCallback ( [ & hit , & note ] { hit = true ; note . Notify ( ) ; } ) ; } ) ; note . WaitForNotification ( ) ; EXPECT_TRUE ( hit ) ; }
Tests that WarnIfInCallback() triggers correctly.
Tests that WarnIfInCallback () triggers correctly .