main.cpp 706 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <QCoreApplication>
  2. #include <thread>
  3. #include "ivbacktrace.h"
  4. #include "ivlog.h"
  5. #include "ivfault.h"
  6. #include "ivexit.h"
  7. iv::Ivlog * givlog;
  8. void testthread()
  9. {
  10. int i;
  11. i = 0;
  12. while(i<3)
  13. {
  14. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  15. i++;
  16. }
  17. // int *p = 0;
  18. // *p = 1;
  19. }
  20. void exitcall()
  21. {
  22. givlog->warn("testivexit exit.");
  23. std::this_thread::sleep_for(std::chrono::milliseconds(100));
  24. }
  25. int main(int argc, char *argv[])
  26. {
  27. QCoreApplication a(argc, argv);
  28. RegisterIVBackTrace();
  29. givlog = new iv::Ivlog("testivexit");
  30. iv::ivexit::RegIVExitCall(exitcall);
  31. std::thread at(testthread);
  32. return a.exec();
  33. }