1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 21:07:35 +00:00

Import all this stuff into a single repo called Serenity.

This commit is contained in:
Andreas Kling 2018-10-10 11:53:07 +02:00
commit 5a30055157
67 changed files with 8836 additions and 0 deletions

43
AK/Retainable.h Normal file
View file

@ -0,0 +1,43 @@
#pragma once
#include "Assertions.h"
namespace AK {
template<typename T>
class Retainable {
public:
Retainable() { }
void retain()
{
ASSERT(m_retainCount);
++m_retainCount;
}
void release()
{
assert(m_retainCount);
if (!--m_retainCount)
delete static_cast<const T*>(this);
}
int retainCount() const
{
return m_retainCount;
}
protected:
~Retainable()
{
ASSERT(!m_retainCount);
}
private:
int m_retainCount { 1 };
};
}
using AK::Retainable;