Changeset 1f96ec for src


Ignore:
Timestamp:
Oct 30, 2015, 11:43:20 AM (10 years ago)
Author:
Frederik Heber <heber@…>
Children:
dd7c44
Parents:
959c82
git-author:
Frederik Heber <heber@…> (07/10/15 08:28:17)
git-committer:
Frederik Heber <heber@…> (10/30/15 11:43:20)
Message:

Channels has its own mutex now, too.

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/CodePatterns/Observer/Channels.hpp

    r959c82 r1f96ec  
    1515
    1616#include <map>
     17
     18#include <boost/thread/recursive_mutex.hpp>
    1719
    1820#include "CodePatterns/Observer/defs.hpp"
     
    6466
    6567  NotificationTypetoRefMap ChannelMap;
     68
     69  mutable boost::recursive_mutex ChannelLock; //!< a lock for the pointer of the instance
    6670};
    6771
  • src/Observer/Channels.cpp

    r959c82 r1f96ec  
    2020#include "CodePatterns/MemDebug.hpp"
    2121
     22#include <boost/thread/locks.hpp>
     23
    2224#include "CodePatterns/Assert.hpp"
    2325
     
    3133Channels::~Channels()
    3234{
     35  boost::recursive_mutex::scoped_lock guard(ChannelLock);
    3336  // free all present Notifications
    3437  for(NotificationTypetoRefMap::iterator iter = ChannelMap.begin();
     
    4043void Channels::addChannel(size_t no)
    4144{
     45  boost::recursive_mutex::scoped_lock guard(ChannelLock);
    4246#ifndef NDEBUG
    4347  NotificationTypetoRefMap::const_iterator iter = ChannelMap.find(no);
     
    5054void Channels::removeChannel(size_t no)
    5155{
     56  boost::recursive_mutex::scoped_lock guard(ChannelLock);
    5257  NotificationTypetoRefMap::iterator iter = ChannelMap.find(no);
    5358  ASSERT(iter != ChannelMap.end(),
     
    5964void Channels::subjectKilled(Observable * const publisher)
    6065{
     66  boost::recursive_mutex::scoped_lock guard(ChannelLock);
    6167  for(NotificationTypetoRefMap::iterator iter = ChannelMap.begin();
    6268      iter != ChannelMap.end();++iter) {
     
    6773Notification_ptr Channels::getChannel(size_t no) const
    6874{
     75  boost::recursive_mutex::scoped_lock guard(ChannelLock);
    6976  NotificationTypetoRefMap::const_iterator iter = ChannelMap.find(no);
    7077  ASSERT(iter != ChannelMap.end(),
     
    7582size_t Channels::getType(Notification_ptr channel) const
    7683{
     84  boost::recursive_mutex::scoped_lock guard(ChannelLock);
    7785  return channel->getChannelNo();
    7886}
Note: See TracChangeset for help on using the changeset viewer.