main.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #include "spdlog/spdlog.h"
  2. #include "SPAServer.h"
  3. #include "LHLogInit.h"
  4. #include "LHQLogAPI.h"
  5. #include "ThreadPool/ThreadPool.h"
  6. #include <QCoreApplication>
  7. // #include "RingQueue.hpp"
  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. SPDLOG_ERROR("main logger is nullptr");
  18. return -1;
  19. }
  20. SPDLOG_LOGGER_INFO(logger, "★ ★ ★ ★ ★ ★ ☆ ☆ SecurePlayAuxServer ☆ ☆ ★ ★ ★ ★ ★ ★");
  21. /* 设置线程池最大线程个数 */
  22. CPPTP.setThreadMaxNum(256);
  23. SPAServer server;
  24. // server.startServer();
  25. // return app.exec();
  26. // test1();
  27. }
  28. struct Test
  29. {
  30. Test() {
  31. SPDLOG_INFO("构造函数, t:{}", t);
  32. }
  33. Test(const Test& o) {
  34. t = o.t;
  35. SPDLOG_INFO("拷贝构造函数, t:{}", t);
  36. }
  37. Test& operator=(const Test& o) {
  38. t = o.t;
  39. SPDLOG_INFO("赋值构造函数, t:{}", t);
  40. return *this;
  41. }
  42. ~Test() {
  43. SPDLOG_INFO("析构函数");
  44. }
  45. int t = 0;
  46. };
  47. Test& test2();
  48. Test test3();
  49. std::list<Test> listTest;
  50. void test1()
  51. {
  52. Test t;
  53. listTest.push_back(t);
  54. SPDLOG_INFO("--------------------------");
  55. SPDLOG_INFO("t:{}", t.t);
  56. auto it = listTest.front();
  57. it.t = 1;
  58. auto it1 = listTest.front();
  59. SPDLOG_INFO("it:{}", it1.t);
  60. SPDLOG_INFO("--------------------------");
  61. auto& it2 = listTest.front();
  62. it2.t = 2;
  63. SPDLOG_INFO("it2:{}", listTest.front().t);
  64. SPDLOG_INFO("--------------------------");
  65. auto& it3 = test2();
  66. SPDLOG_INFO("it3:{}", it3.t);
  67. SPDLOG_INFO("--------------------------");
  68. auto it4 = test3();
  69. SPDLOG_INFO("it4:{}", it4.t);
  70. }
  71. Test& test2()
  72. {
  73. Test t;
  74. t.t = 10;
  75. listTest.push_front(t);
  76. return listTest.front();
  77. }
  78. Test test3()
  79. {
  80. Test t;
  81. t.t = 10;
  82. listTest.push_front(t);
  83. return listTest.front();
  84. }