From 9eb5d398a0ea10c39b30ebf2789c6ae365c1895e Mon Sep 17 00:00:00 2001 From: Diana Pinto Date: Fri, 4 Oct 2024 15:22:36 +0100 Subject: [PATCH] capicxx-core-runtime 3.2.4 - Added github workflow to build the project in Ubuntu and Windows - Fix Copyright & github link in README - (dev) Warn about multiple subscriptions --- Android.bp | 2 +- CHANGES | 7 +++++++ CMakeLists.txt | 4 ++-- include/CommonAPI/Event.hpp | 12 +++++++++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Android.bp b/Android.bp index 93dc072..fa8e513 100644 --- a/Android.bp +++ b/Android.bp @@ -4,7 +4,7 @@ cc_defaults { rtti: true, cppflags: [ - "-std=c++11", + "-std=c++17", "-Wall", "-Wextra", "-Wformat", diff --git a/CHANGES b/CHANGES index 87db39e..7b9f739 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,13 @@ Changes ======= +v3.2.4 +- Added github workflow to build the project in Ubuntu and Windows + +v3.2.3-r8 +- Fix Copyright & github link in README +- (dev) Warn about multiple subscriptions + v3.2.3-r7 - Fixed warnings with gcc11 for Wextra-extra-semi flag - Fix capi-core-runtime Runtime::loadLibrary diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cade2a..11eb544 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ PROJECT(libcommonapi) # version of CommonAPI SET( LIBCOMMONAPI_MAJOR_VERSION 3 ) SET( LIBCOMMONAPI_MINOR_VERSION 2 ) -SET( LIBCOMMONAPI_PATCH_VERSION 3 ) +SET( LIBCOMMONAPI_PATCH_VERSION 4 ) message(STATUS "Project name: ${PROJECT_NAME}") @@ -106,7 +106,7 @@ IF(MSVC) add_definitions(-DCOMMONAPI_INTERNAL_COMPILATION -DCOMMONAPI_DLL_COMPILATION) add_compile_options(/EHsc /wd4996) ELSE () - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Werror=extra-semi -Wformat -Wformat-security -Wconversion -fexceptions -fstrict-aliasing -fstack-protector-strong -fasynchronous-unwind-tables -fno-omit-frame-pointer -Werror -DCOMMONAPI_INTERNAL_COMPILATION -fvisibility=hidden") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -Wextra -Werror=extra-semi -Wformat -Wformat-security -Wconversion -fexceptions -fstrict-aliasing -fstack-protector-strong -fasynchronous-unwind-tables -fno-omit-frame-pointer -Werror -DCOMMONAPI_INTERNAL_COMPILATION -fvisibility=hidden") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wformat-security -fstack-protector-strong") ENDIF(MSVC) diff --git a/include/CommonAPI/Event.hpp b/include/CommonAPI/Event.hpp index 116d6b3..9512cbf 100644 --- a/include/CommonAPI/Event.hpp +++ b/include/CommonAPI/Event.hpp @@ -90,6 +90,16 @@ class Event { (void)_listener; } + /** + * \brief Get the number of subscriptions to this event. + * + * \warning This method acquires a lock on `subscriptionMutex_`. + */ + std::size_t getSubscriptionCount() const { + std::lock_guard itsSubscriptionLock(subscriptionMutex_); + return subscriptions_.size(); + } + private: ListenersMap subscriptions_; Subscription nextSubscription_; @@ -98,7 +108,7 @@ class Event { SubscriptionsSet pendingUnsubscriptions_; std::mutex notificationMutex_; - std::mutex subscriptionMutex_; + mutable std::mutex subscriptionMutex_; }; template