mirror of
				https://github.com/Icinga/icinga2.git
				synced 2025-11-04 05:34:12 +01:00 
			
		
		
		
	Copying an ObjectLock results in the underlying mutex being unlocked too often. There's also no good reason for copying a scoped locking class (if at all, it should be moved).
		
			
				
	
	
		
			36 lines
		
	
	
		
			522 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			522 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(const ObjectLock&) = delete;
 | 
						|
	ObjectLock& operator=(const ObjectLock&) = delete;
 | 
						|
 | 
						|
	~ObjectLock();
 | 
						|
 | 
						|
	void Lock();
 | 
						|
	void Unlock();
 | 
						|
 | 
						|
private:
 | 
						|
	const Object *m_Object{nullptr};
 | 
						|
	bool m_Locked{false};
 | 
						|
};
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
#endif /* OBJECTLOCK_H */
 |