From 88ce90857a83a056461bd17496b2296dc000041a Mon Sep 17 00:00:00 2001 From: zcy <290198252@qq.com> Date: Thu, 18 Nov 2021 14:44:48 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9B=86=E6=88=90gtest=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- general/src/threadsafe/thread_safe_list.hpp | 20 +++----------------- test/src/cpp11/CMakeLists.txt | 13 ++++++++++++- test/src/cpp11/cpp11_test.cpp | 6 +++--- test/src/uv_test/test.cpp | 1 + 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/general/src/threadsafe/thread_safe_list.hpp b/general/src/threadsafe/thread_safe_list.hpp index b178e6b..8b0d0fb 100644 --- a/general/src/threadsafe/thread_safe_list.hpp +++ b/general/src/threadsafe/thread_safe_list.hpp @@ -1,7 +1,7 @@ /* * @Author: caiyuzheng * @Date: 2021-10-06 23:05:26 - * @LastEditTime: 2021-11-17 17:24:46 + * @LastEditTime: 2021-11-18 11:14:20 * @LastEditors: Please set LastEditors * @Description: In User Settings Edit * @FilePath: \generallib\general\src\threadsafe\thread_safe_list.h @@ -75,20 +75,18 @@ public: return 0; } using vIterator = typename std::list::iterator; - vIterator PopFront() + vIterator Front() { if (!m_data.empty()) { m_mux.lock(); auto ret = m_data.begin(); - auto ret1 = *ret; - m_data.erase(ret); m_mux.unlock(); + return ret; } return m_data.end(); } - T PopFrontAndWait() { if (!m_data.empty()) @@ -121,18 +119,6 @@ public: } } - T Front() - { - if (!m_data.empty()) - { - m_mux.lock(); - auto ret = m_data.front(); - m_mux.unlock(); - return ret; - } - return T(); - } - uint32_t Length() { return m_data.size(); diff --git a/test/src/cpp11/CMakeLists.txt b/test/src/cpp11/CMakeLists.txt index e968ebe..b1a6fb4 100644 --- a/test/src/cpp11/CMakeLists.txt +++ b/test/src/cpp11/CMakeLists.txt @@ -2,15 +2,26 @@ cmake_minimum_required(VERSION 3.12) project(cpp11) add_definitions(-std=c++11) + +set(CMAKE_BUILD_TYPE DEBUG) +set(CMAKE_CXX_FLAGS " /MTd ") +set(CMAKE_CXX_FLAGS_DEBUG "/DEBUG") +set(CMAKE_CXX_FLAGS_RELEASE "") + message("current dir" ${CMAKE_CURRENT_SOURCE_DIR}) -# set(CMAKE_CXX_FLAGS "-fno-elide-constructors") message(info ${SOURCE}) link_directories("./third/jsoncpp/lib/") link_directories("../../../obj/") +link_directories("./third/gtest/lib") link_libraries(generallib) +link_libraries(gtestd) add_executable(cpp11 cpp11_test.cpp ) +add_executable(gtest gtest.cpp ) + include_directories("./third/jsoncpp/include/pkgsrc/include/json") include_directories("../../../obj/inc/") +include_directories("./third/gtest/include") + diff --git a/test/src/cpp11/cpp11_test.cpp b/test/src/cpp11/cpp11_test.cpp index 0bf57cf..34334e3 100644 --- a/test/src/cpp11/cpp11_test.cpp +++ b/test/src/cpp11/cpp11_test.cpp @@ -1,7 +1,7 @@ /* * @Author: your name * @Date: 2021-03-15 23:07:25 - * @LastEditTime: 2021-11-17 17:17:37 + * @LastEditTime: 2021-11-18 11:14:15 * @LastEditors: Please set LastEditors * @Description: In User Settings Edit * @FilePath: \cpp11\cpp11_test.cpp @@ -41,11 +41,11 @@ int main(int argc, char **argv) ((ThreadSafeList*)p)->PushFront(123); }); + auto x = ip.Front(); + std::cout<<*x<<"\r\n"; std::cout<