diff --git a/components/simdjson_component/SConstruct b/components/simdjson_component/SConstruct index b0f979f..36ffcf2 100644 --- a/components/simdjson_component/SConstruct +++ b/components/simdjson_component/SConstruct @@ -14,7 +14,7 @@ if "CONFIG_SIMDJSON_COMPENENT_ENABLED" in os.environ: STATIC_LIB = [] DYNAMIC_LIB = [] DEFINITIONS = [] - DEFINITIONS_PRIVATE = [] + DEFINITIONS_PRIVATE = ['-O2'] LDFLAGS = [] LINK_SEARCH_PATH = [] DEFINITIONS += ['-std=c++17'] diff --git a/components/utilities/include/thread_safe_list.h b/components/utilities/include/thread_safe_list.h index c330905..a59dd08 100644 --- a/components/utilities/include/thread_safe_list.h +++ b/components/utilities/include/thread_safe_list.h @@ -1,13 +1,15 @@ /* Thread Safe Version STL in C++11 Copyright(c) 2021 -Author: tashaxing +Author: tashaxing, dianjixz +update: 2025,04,02. add get put */ #ifndef THREAD_SAFE_LIST_H_INCLUDED #define THREAD_SAFE_LIST_H_INCLUDED #include #include +#include namespace thread_safe { @@ -117,9 +119,14 @@ public: // Allocator allocator_type get_allocator( void ) const { std::lock_guard lock( mutex ); return storage.get_allocator(); } + T get() { std::unique_lock lock(mutex); cond_var.wait(lock, [this] { return !storage.empty(); }); T value = storage.front(); storage.pop_front(); return value; } + void put(const T& value) { std::lock_guard lock(mutex); storage.push_back(value); cond_var.notify_one(); } + void put(T&& value) { std::lock_guard lock(mutex); storage.emplace_back(std::move(value)); cond_var.notify_one(); } + private: std::list storage; mutable std::mutex mutex; + std::condition_variable cond_var; }; }