icinga2/lib/base/objectlock.hpp

36 lines
522 B
C++
Raw Normal View History

/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2013-02-24 08:27:00 +01:00
#ifndef OBJECTLOCK_H
#define OBJECTLOCK_H
2014-05-25 16:23:35 +02:00
#include "base/object.hpp"
2013-03-16 21:18:53 +01:00
2013-02-24 08:27:00 +01:00
namespace icinga
{
/**
* A scoped lock for Objects.
*/
2017-12-31 07:22:16 +01:00
struct ObjectLock
{
2013-02-24 08:27:00 +01:00
public:
ObjectLock(const Object::Ptr& object);
ObjectLock(const Object *object);
ObjectLock(const ObjectLock&) = delete;
ObjectLock& operator=(const ObjectLock&) = delete;
~ObjectLock();
2014-11-12 06:33:20 +01:00
void Lock();
void Unlock();
2013-02-24 08:27:00 +01:00
private:
const Object *m_Object{nullptr};
bool m_Locked{false};
2013-02-24 08:27:00 +01:00
};
}
#endif /* OBJECTLOCK_H */