From 5ec9f085e1a4fa408a6419338f1e705596d4136d Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Tue, 8 Nov 2011 19:03:02 +0100 Subject: [PATCH] compiler warnings, userValue sync --- pvAccessApp/client/pvAccess.h | 3 +++ pvAccessApp/remote/channelSearchManager.h | 2 +- pvAccessApp/remote/simpleChannelSearchManagerImpl.cpp | 7 +++++++ pvAccessApp/remote/simpleChannelSearchManagerImpl.h | 5 +++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pvAccessApp/client/pvAccess.h b/pvAccessApp/client/pvAccess.h index b45f4d3..bbe49e4 100644 --- a/pvAccessApp/client/pvAccess.h +++ b/pvAccessApp/client/pvAccess.h @@ -40,6 +40,8 @@ namespace pvAccess { { public: POINTER_DEFINITIONS(Lockable); + + virtual ~Lockable() {}; virtual void lock() = 0; virtual void unlock() = 0; @@ -192,6 +194,7 @@ namespace pvAccess { public: POINTER_DEFINITIONS(ChannelFindRequester); + virtual ~ChannelFindRequester() {}; /** * @param status Completion status. */ diff --git a/pvAccessApp/remote/channelSearchManager.h b/pvAccessApp/remote/channelSearchManager.h index d074976..95e64f9 100644 --- a/pvAccessApp/remote/channelSearchManager.h +++ b/pvAccessApp/remote/channelSearchManager.h @@ -92,4 +92,4 @@ class ChannelSearchManager { } } -#endif \ No newline at end of file +#endif diff --git a/pvAccessApp/remote/simpleChannelSearchManagerImpl.cpp b/pvAccessApp/remote/simpleChannelSearchManagerImpl.cpp index 57abe88..c5ee607 100644 --- a/pvAccessApp/remote/simpleChannelSearchManagerImpl.cpp +++ b/pvAccessApp/remote/simpleChannelSearchManagerImpl.cpp @@ -44,6 +44,8 @@ SimpleChannelSearchManagerImpl::SimpleChannelSearchManagerImpl(Context::shared_p m_timerNode(*this), m_lastTimeSent(), m_mockTransportSendControl(), + m_channelMutex(), + m_userValueMutex(), m_mutex() { // initialize send buffer @@ -90,6 +92,8 @@ void SimpleChannelSearchManagerImpl::registerSearchInstance(SearchInstance::shar Lock guard(m_channelMutex); //overrides if already registered m_channels[channel->getSearchInstanceID()] = channel; + + Lock guard2(m_userValueMutex); int32_t& userValue = channel->getUserValue(); userValue = 1; } @@ -222,6 +226,7 @@ bool SimpleChannelSearchManagerImpl::generateSearchRequestMessage(SearchInstance void SimpleChannelSearchManagerImpl::boost() { Lock guard(m_channelMutex); + Lock guard2(m_userValueMutex); std::map::iterator channelsIter = m_channels.begin(); for(; channelsIter != m_channels.end(); channelsIter++) { @@ -260,6 +265,7 @@ void SimpleChannelSearchManagerImpl::callback() vector::iterator siter = toSend.begin(); for (; siter != toSend.end(); siter++) { + m_userValueMutex.lock(); int32_t& countValue = (*siter)->getUserValue(); bool skip = !isPowerOfTwo(countValue); @@ -267,6 +273,7 @@ void SimpleChannelSearchManagerImpl::callback() countValue = MAX_FALLBACK_COUNT_VALUE; else countValue++; + m_userValueMutex.unlock(); // back-off if (skip) diff --git a/pvAccessApp/remote/simpleChannelSearchManagerImpl.h b/pvAccessApp/remote/simpleChannelSearchManagerImpl.h index 6387a6b..60de546 100644 --- a/pvAccessApp/remote/simpleChannelSearchManagerImpl.h +++ b/pvAccessApp/remote/simpleChannelSearchManagerImpl.h @@ -144,6 +144,11 @@ class SimpleChannelSearchManagerImpl : public ChannelSearchManager, public epics */ epics::pvData::Mutex m_channelMutex; + /** + * User value lock. + */ + epics::pvData::Mutex m_userValueMutex; + /** * m_channels mutex. */