BlinkenArea - GitList
Repositories
Blog
Wiki
Blinker
Code
Commits
Branches
Tags
Search
Tree:
7d3347c
Branches
Tags
master
Blinker
src
common
SyncMgr.cpp
implement synchronization streams and managers
Stefan Schuermans
commited
7d3347c
at 2014-01-03 14:54:06
SyncMgr.cpp
Blame
History
Raw
/* Blinker Copyright 2011-2014 Stefan Schuermans <stefan@blinkenarea.org> Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html a blinkenarea.org project */ #include <map> #include <string> #include "Sync.h" #include "SyncMgr.h" namespace Blinker { /// constructor SyncMgr::SyncMgr() { } /// destructor SyncMgr::~SyncMgr() { } /** * @brief reference sync stream * @param[in] name sync stream name * @return sync stream * * if the sync stream does not exists, it is created */ Sync & SyncMgr::refSync(const std::string &name) { Entry &entry = m_syncs[name]; entry.m_sync.m_name = name; entry.m_refCnt++; return entry.m_sync; } /** * @brief unreference sync stream * @param[in] name sync stream name * * if the last reference is removed, the sync stream is deleted */ void SyncMgr::unrefSync(const std::string &name) { SyncMap::iterator itSync = m_syncs.find(name); if (itSync != m_syncs.end()) { if (itSync->second.m_refCnt > 0) itSync->second.m_refCnt--; if (itSync->second.m_refCnt == 0) m_syncs.erase(itSync); } } /* ################## # SyncMgr::Entry # ################## */ /// constructor SyncMgr::Entry::Entry(): m_refCnt(0) { } } // namespace Blinker