mirror of https://github.com/Icinga/icinga2.git
38 lines
513 B
C++
38 lines
513 B
C++
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
|
|
|
#ifndef OBJECTLOCK_H
|
|
#define OBJECTLOCK_H
|
|
|
|
#include "base/object.hpp"
|
|
|
|
namespace icinga
|
|
{
|
|
|
|
/**
|
|
* A scoped lock for Objects.
|
|
*/
|
|
struct ObjectLock
|
|
{
|
|
public:
|
|
ObjectLock(const Object::Ptr& object);
|
|
ObjectLock(const Object *object);
|
|
|
|
~ObjectLock();
|
|
|
|
static void LockMutex(const Object *object);
|
|
|
|
void Lock();
|
|
|
|
static void Spin(unsigned int it);
|
|
|
|
void Unlock();
|
|
|
|
private:
|
|
const Object *m_Object{nullptr};
|
|
bool m_Locked{false};
|
|
};
|
|
|
|
}
|
|
|
|
#endif /* OBJECTLOCK_H */
|