From 1f8a2508454107a054e908d9e306614f63dbca16 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 4 Dec 2024 15:38:52 +0800 Subject: [PATCH] feat remove marl --- CMakeLists.txt | 10 +++++----- src/sled/event_bus/event_bus.h | 3 ++- src/sled/network/physical_socket_server.h | 22 ++++++++++----------- src/sled/sled.h | 4 ++-- src/sled/synchronization/mutex.h | 18 +++++++++++------ src/sled/synchronization/one_time_event.h | 2 +- src/sled/synchronization/sequence_checker.h | 6 +++--- src/sled/system/thread.h | 6 +++--- src/sled/system/thread_pool.h | 2 +- 9 files changed, 40 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 433540d..b680007 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,9 +39,9 @@ add_subdirectory(3party/minilua EXCLUDE_FROM_ALL) if(SLED_WITH_PROTOBUF) add_subdirectory(3party/protobuf-3.21.12 EXCLUDE_FROM_ALL) endif() -if(NOT TARGET marl) - add_subdirectory(3party/marl EXCLUDE_FROM_ALL) -endif() +# if(NOT TARGET marl) +# add_subdirectory(3party/marl EXCLUDE_FROM_ALL) +# endif() if(NOT TARGET rpc_core) add_subdirectory(3party/rpc_core EXCLUDE_FROM_ALL) @@ -106,7 +106,7 @@ target_sources( target_link_libraries( sled - PUBLIC rpc_core fmt marl minilua asio + PUBLIC rpc_core fmt minilua asio # protobuf::libprotoc PRIVATE dl) # if(CMAKE_SYSTEM_NAME STREQUAL "Linux") target_link_libraries(sled PUBLIC @@ -191,7 +191,7 @@ if(SLED_BUILD_TESTS) src/sled/status_or_test.cc src/sled/strings/utils_test.cc src/sled/strings/base64_test.cc - src/sled/system/fiber/fiber_test.cc + # src/sled/system/fiber/fiber_test.cc src/sled/system/thread_pool_test.cc # src/sled/rx_test.cc src/sled/uri_test.cc) diff --git a/src/sled/event_bus/event_bus.h b/src/sled/event_bus/event_bus.h index 7bdb663..7b68f5a 100644 --- a/src/sled/event_bus/event_bus.h +++ b/src/sled/event_bus/event_bus.h @@ -5,6 +5,7 @@ #include "sled/sigslot.h" #include "sled/synchronization/mutex.h" #include +#include namespace sled { @@ -181,7 +182,7 @@ public: private: sled::Mutex mutex_; - std::unordered_map> cleanup_handlers_ GUARDED_BY(mutex_); + std::unordered_map> cleanup_handlers_;//GUARDED_BY(mutex_); }; }// namespace sled #endif// SLED_EVENT_BUS_EVENT_BUS_H diff --git a/src/sled/network/physical_socket_server.h b/src/sled/network/physical_socket_server.h index 5dd354e..7c7290a 100644 --- a/src/sled/network/physical_socket_server.h +++ b/src/sled/network/physical_socket_server.h @@ -20,22 +20,22 @@ typedef int SOCKET; namespace sled { enum DispatcherEvent { - DE_READ = 0x0001, - DE_WRITE = 0x0002, + DE_READ = 0x0001, + DE_WRITE = 0x0002, DE_CONNECT = 0x0004, - DE_CLOSE = 0x0008, - DE_ACCEPT = 0x0010, + DE_CLOSE = 0x0008, + DE_ACCEPT = 0x0010, }; class Signaler; class Dispatcher { public: - virtual ~Dispatcher() = default; - virtual uint32_t GetRequestedEvents() = 0; + virtual ~Dispatcher() = default; + virtual uint32_t GetRequestedEvents() = 0; virtual void OnEvent(uint32_t ff, int err) = 0; - virtual int GetDescriptor() = 0; + virtual int GetDescriptor() = 0; virtual bool IsDescriptorClosed() = 0; }; @@ -59,9 +59,9 @@ private: bool WaitSelect(int64_t cusWait, bool process_io); uint64_t next_dispatcher_key_ = 0; - std::unordered_map dispatcher_by_key_ GUARDED_BY(lock_); - std::unordered_map key_by_dispatcher_ GUARDED_BY(lock_); - std::vector current_dispatcher_keys_ GUARDED_BY(lock_); + std::unordered_map dispatcher_by_key_;//GUARDED_BY(lock_); + std::unordered_map key_by_dispatcher_;//GUARDED_BY(lock_); + std::vector current_dispatcher_keys_; //GUARDED_BY(lock_); Signaler *signal_wakeup_; // Mutex lock_; RecursiveMutex lock_; @@ -124,7 +124,7 @@ protected: bool udp_; int family_ = 0; mutable Mutex mutex_; - int error_ GUARDED_BY(mutex_); + int error_;//GUARDED_BY(mutex_); ConnState state_; AsyncResolver *resolver_; diff --git a/src/sled/sled.h b/src/sled/sled.h index a5c475f..9a5e8b0 100644 --- a/src/sled/sled.h +++ b/src/sled/sled.h @@ -65,8 +65,8 @@ #include "sled/synchronization/sequence_checker.h" #include "sled/synchronization/thread_local.h" // system -#include "sled/system/fiber/scheduler.h" -#include "sled/system/fiber/wait_group.h" +// #include "sled/system/fiber/scheduler.h" +// #include "sled/system/fiber/wait_group.h" #include "sled/system/location.h" #include "sled/system/thread.h" #include "sled/system/thread_pool.h" diff --git a/src/sled/synchronization/mutex.h b/src/sled/synchronization/mutex.h index c9e1a06..7d6a920 100644 --- a/src/sled/synchronization/mutex.h +++ b/src/sled/synchronization/mutex.h @@ -11,8 +11,11 @@ #include "sled/lang/attributes.h" #include "sled/units/time_delta.h" #include -#include -#include +// #include +// #include +#include +#include +#include // #include // #include #include @@ -50,7 +53,8 @@ public: inline void Unlock() SLED_UNLOCK_FUNCTION(impl_) { impl_.unlock(); } private: - marl::mutex impl_; + // marl::mutex impl_; + std::mutex impl_; friend class ConditionVariable; friend class MutexLock; }; @@ -110,7 +114,8 @@ public: private: friend class ConditionVariable; - marl::lock lock_; + // marl::lock lock_; + std::unique_lock lock_; }; class ConditionVariable final { @@ -143,10 +148,11 @@ public: } private: - marl::ConditionVariable cv_; + std::condition_variable cv_; + // marl::ConditionVariable cv_; }; -class SCOPED_CAPABILITY SharedMutex final { +class SharedMutex final { public: enum class Mode { kReaderPriority, diff --git a/src/sled/synchronization/one_time_event.h b/src/sled/synchronization/one_time_event.h index e9c4820..d6a701c 100644 --- a/src/sled/synchronization/one_time_event.h +++ b/src/sled/synchronization/one_time_event.h @@ -25,7 +25,7 @@ public: } private: - bool happended_ GUARDED_BY(mutex_) = false; + bool happended_;//GUARDED_BY(mutex_) = false; Mutex mutex_; }; diff --git a/src/sled/synchronization/sequence_checker.h b/src/sled/synchronization/sequence_checker.h index 9e06c6d..d42d82f 100644 --- a/src/sled/synchronization/sequence_checker.h +++ b/src/sled/synchronization/sequence_checker.h @@ -30,9 +30,9 @@ public: private: mutable Mutex mutex_; - mutable bool attached_ GUARDED_BY(mutex_); - mutable pthread_t valid_thread_ GUARDED_BY(mutex_); - mutable const TaskQueueBase *valid_queue_ GUARDED_BY(mutex_); + mutable bool attached_; //GUARDED_BY(mutex_); + mutable pthread_t valid_thread_; //GUARDED_BY(mutex_); + mutable const TaskQueueBase *valid_queue_;//GUARDED_BY(mutex_); }; class SequenceCheckerDoNothing { diff --git a/src/sled/system/thread.h b/src/sled/system/thread.h index ef8a21a..c8f9185 100644 --- a/src/sled/system/thread.h +++ b/src/sled/system/thread.h @@ -135,9 +135,9 @@ private: void ClearCurrentTaskQueue(); mutable Mutex mutex_; - std::queue> messages_ GUARDED_BY(mutex_); - std::priority_queue delayed_messages_ GUARDED_BY(mutex_); - uint32_t delayed_next_num_ GUARDED_BY(mutex_); + std::queue> messages_; //GUARDED_BY(mutex_); + std::priority_queue delayed_messages_;//GUARDED_BY(mutex_); + uint32_t delayed_next_num_; //GUARDED_BY(mutex_); bool fInitialized_; bool fDestroyed_; std::atomic stop_; diff --git a/src/sled/system/thread_pool.h b/src/sled/system/thread_pool.h index 758a316..ba38075 100644 --- a/src/sled/system/thread_pool.h +++ b/src/sled/system/thread_pool.h @@ -2,7 +2,7 @@ #ifndef SLED_SYSTEM_THREAD_POOL_H #define SLED_SYSTEM_THREAD_POOL_H #include "sled/synchronization/mutex.h" -#include "sled/system/fiber/scheduler.h" +// #include "sled/system/fiber/scheduler.h" #include "sled/system/thread.h" #include #include