main.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #include "spdlog/spdlog.h"
  2. #include "SPAServer.h"
  3. #include "LHLogInit.h"
  4. #include "LHQLogAPI.h"
  5. #include "ThreadPool.h"
  6. #include "GlobalConfig.h"
  7. #include <QCoreApplication>
  8. void test1();
  9. int main(int argc, char* argv[])
  10. {
  11. QCoreApplication app(argc, argv);
  12. /* 初始化日志库 */
  13. initLog("SecurePlayAuxServer", g_apiLhQLog);
  14. auto logger = spdlog::get("main");
  15. if(logger == nullptr)
  16. {
  17. fmt::print("main logger is nullptr");
  18. return -1;
  19. }
  20. SPDLOG_LOGGER_INFO(logger, "★ ★ ★ ★ ★ ★ ☆ ☆ SecurePlayAuxServer ☆ ☆ ★ ★ ★ ★ ★ ★");
  21. /* 设置线程池最大线程个数 */
  22. CPPTP.setThreadMaxNum(256);
  23. /* 初始化服务配置 */
  24. GConfig.initService();
  25. SPAServer server;
  26. server.startServer();
  27. return app.exec();
  28. // test1();
  29. }
  30. struct Test
  31. {
  32. Test() {
  33. SPDLOG_INFO("构造函数, t:{}", t);
  34. }
  35. Test(const Test& o) {
  36. t = o.t;
  37. SPDLOG_INFO("拷贝构造函数, t:{}", t);
  38. }
  39. Test& operator=(const Test& o) {
  40. t = o.t;
  41. SPDLOG_INFO("赋值构造函数, t:{}", t);
  42. return *this;
  43. }
  44. ~Test() {
  45. SPDLOG_INFO("析构函数");
  46. }
  47. int t = 0;
  48. };
  49. Test& test2();
  50. Test test3();
  51. std::list<Test> listTest;
  52. void test1()
  53. {
  54. Test t;
  55. listTest.push_back(t);
  56. SPDLOG_INFO("--------------------------");
  57. SPDLOG_INFO("t:{}", t.t);
  58. auto it = listTest.front();
  59. it.t = 1;
  60. auto it1 = listTest.front();
  61. SPDLOG_INFO("it:{}", it1.t);
  62. SPDLOG_INFO("--------------------------");
  63. auto& it2 = listTest.front();
  64. it2.t = 2;
  65. SPDLOG_INFO("it2:{}", listTest.front().t);
  66. SPDLOG_INFO("--------------------------");
  67. auto& it3 = test2();
  68. SPDLOG_INFO("it3:{}", it3.t);
  69. SPDLOG_INFO("--------------------------");
  70. auto it4 = test3();
  71. SPDLOG_INFO("it4:{}", it4.t);
  72. }
  73. Test& test2()
  74. {
  75. Test t;
  76. t.t = 10;
  77. listTest.push_front(t);
  78. return listTest.front();
  79. }
  80. Test test3()
  81. {
  82. Test t;
  83. t.t = 10;
  84. listTest.push_front(t);
  85. return listTest.front();
  86. }