test.cpp 749 B

12345678910111213141516171819202122232425262728293031323334
  1. #include <iostream>
  2. #include <signal.h>
  3. #include "TestApp.hpp"
  4. using namespace std;
  5. int main(int argc, char* argv[]){
  6. static semaphore sem;
  7. signal(SIGINT, [](int) {
  8. sem.post();
  9. NoticeCenter::Instance().emitEvent(NOTICE_DESTROY);
  10. });
  11. Logger::Instance().add(std::make_shared<ConsoleChannel>());
  12. Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());
  13. gsd::TestApp::Ptr app = gsd::TestApp::CreateNew();
  14. if(app == nullptr){
  15. ErrorL << "App unable to create"<<endl;
  16. return -1;
  17. }
  18. if(app->Init()==false){
  19. ErrorL << "Failed to start task"<<endl;
  20. }
  21. app->StartTask();
  22. sem.wait();
  23. InfoL<<"app Destroy"<<endl;
  24. app->Destroy();
  25. return 0;
  26. }