#include <cstddef>
#include <map>
#include <memory>
-#include <dpl/mutex.h>
-#include <dpl/shared_ptr.h>
+#include <mutex>
#include <Commons/ListenerEventEmitter.h>
namespace WrtDeviceApis {
{
public:
typedef EmitterClass EmitterType;
- typedef DPL::SharedPtr<EmitterType> EmitterPtrType;
+ typedef std::shared_ptr<EmitterType> EmitterPtrType;
typedef typename EmitterType::IdType EmitterIdType;
typedef typename EmitterType::EventType EventType;
typedef typename EmitterType::EventPtrType EventPtrType;
- typedef std::auto_ptr<DPL::Mutex::ScopedLock> LockType;
+ typedef std::shared_ptr<std::lock_guard<std::mutex>> LockType;
public:
~Emitters()
{
- DPL::Mutex::ScopedLock lock(&m_mtx);
+ std::lock_guard<std::mutex> lock(m_mtx);
m_emitters.clear();
}
*/
void attach(const EmitterPtrType& emitter)
{
- DPL::Mutex::ScopedLock lock(&m_mtx);
+ std::lock_guard<std::mutex> lock(m_mtx);
m_emitters[emitter->getId()] = emitter;
}
*/
bool detach(const EmitterIdType id)
{
- DPL::Mutex::ScopedLock lock(&m_mtx);
+ std::lock_guard<std::mutex> lock(m_mtx);
return (m_emitters.erase(id) > 0);
}
*/
void emit(const EventPtrType& event)
{
- DPL::Mutex::ScopedLock lock(&m_mtx);
+ std::lock_guard<std::mutex> lock(m_mtx);
for (Iterator it = m_emitters.begin(); it != m_emitters.end(); ++it) {
it->second->emit(event);
}
void emitIf(const EventPtrType& event,
Predicate pred)
{
- DPL::Mutex::ScopedLock lock(&m_mtx);
+ std::lock_guard<std::mutex> lock(m_mtx);
for (Iterator it = m_emitters.begin(); it != m_emitters.end(); ++it) {
if (bool(pred(it->second))) {
it->second->emit(event);
*/
LockType getLock()
{
- return LockType(new DPL::Mutex::ScopedLock(&m_mtx));
+ return LockType(new std::lock_guard<std::mutex>(m_mtx));
}
private:
typedef typename Map::const_iterator ConstIterator;
private:
- DPL::Mutex m_mtx; ///< Synchronizes operation on this object.
+ std::mutex m_mtx; ///< Synchronizes operation on this object.
Map m_emitters; ///< Emitters container.
};
}