AK: Rename Retainable => RefCounted.
(And various related renames that go along with it.)
This commit is contained in:
parent
ef1bfcb9d8
commit
77b9fa89dd
Notes:
sideshowbarker
2024-07-19 13:32:21 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/77b9fa89dd3
45 changed files with 118 additions and 118 deletions
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace AK {
|
||||
|
||||
class ByteBufferImpl : public Retainable<ByteBufferImpl> {
|
||||
class ByteBufferImpl : public RefCounted<ByteBufferImpl> {
|
||||
public:
|
||||
static Retained<ByteBufferImpl> create_uninitialized(int size);
|
||||
static Retained<ByteBufferImpl> create_zeroed(int);
|
||||
|
|
|
@ -30,7 +30,7 @@ void JsonValue::copy_from(const JsonValue& other)
|
|||
switch (m_type) {
|
||||
case Type::String:
|
||||
m_value.as_string = other.m_value.as_string;
|
||||
AK::retain_if_not_null(m_value.as_string);
|
||||
AK::ref_if_not_null(m_value.as_string);
|
||||
break;
|
||||
case Type::Object:
|
||||
m_value.as_object = new JsonObject(*other.m_value.as_object);
|
||||
|
@ -101,7 +101,7 @@ JsonValue::JsonValue(const String& value)
|
|||
} else {
|
||||
m_type = Type::String;
|
||||
m_value.as_string = const_cast<StringImpl*>(value.impl());
|
||||
AK::retain_if_not_null(m_value.as_string);
|
||||
AK::ref_if_not_null(m_value.as_string);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ void JsonValue::clear()
|
|||
{
|
||||
switch (m_type) {
|
||||
case Type::String:
|
||||
AK::release_if_not_null(m_value.as_string);
|
||||
AK::deref_if_not_null(m_value.as_string);
|
||||
break;
|
||||
case Type::Object:
|
||||
delete m_value.as_object;
|
||||
|
|
|
@ -16,22 +16,22 @@ public:
|
|||
RetainPtr(const T* ptr)
|
||||
: m_ptr(const_cast<T*>(ptr))
|
||||
{
|
||||
retain_if_not_null(m_ptr);
|
||||
ref_if_not_null(m_ptr);
|
||||
}
|
||||
RetainPtr(T* ptr)
|
||||
: m_ptr(ptr)
|
||||
{
|
||||
retain_if_not_null(m_ptr);
|
||||
ref_if_not_null(m_ptr);
|
||||
}
|
||||
RetainPtr(T& object)
|
||||
: m_ptr(&object)
|
||||
{
|
||||
m_ptr->retain();
|
||||
m_ptr->ref();
|
||||
}
|
||||
RetainPtr(const T& object)
|
||||
: m_ptr(const_cast<T*>(&object))
|
||||
{
|
||||
m_ptr->retain();
|
||||
m_ptr->ref();
|
||||
}
|
||||
RetainPtr(AdoptTag, T& object)
|
||||
: m_ptr(&object)
|
||||
|
@ -79,7 +79,7 @@ public:
|
|||
RetainPtr& operator=(RetainPtr&& other)
|
||||
{
|
||||
if (this != &other) {
|
||||
release_if_not_null(m_ptr);
|
||||
deref_if_not_null(m_ptr);
|
||||
m_ptr = other.leak_ref();
|
||||
}
|
||||
return *this;
|
||||
|
@ -89,7 +89,7 @@ public:
|
|||
RetainPtr& operator=(RetainPtr<U>&& other)
|
||||
{
|
||||
if (this != static_cast<void*>(&other)) {
|
||||
release_if_not_null(m_ptr);
|
||||
deref_if_not_null(m_ptr);
|
||||
m_ptr = other.leak_ref();
|
||||
}
|
||||
return *this;
|
||||
|
@ -98,7 +98,7 @@ public:
|
|||
template<typename U>
|
||||
RetainPtr& operator=(Retained<U>&& other)
|
||||
{
|
||||
release_if_not_null(m_ptr);
|
||||
deref_if_not_null(m_ptr);
|
||||
m_ptr = &other.leak_ref();
|
||||
return *this;
|
||||
}
|
||||
|
@ -107,10 +107,10 @@ public:
|
|||
RetainPtr& operator=(const Retained<U>& other)
|
||||
{
|
||||
if (m_ptr != other.ptr())
|
||||
release_if_not_null(m_ptr);
|
||||
deref_if_not_null(m_ptr);
|
||||
m_ptr = const_cast<T*>(other.ptr());
|
||||
ASSERT(m_ptr);
|
||||
retain_if_not_null(m_ptr);
|
||||
ref_if_not_null(m_ptr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -118,27 +118,27 @@ public:
|
|||
RetainPtr& operator=(const RetainPtr<U>& other)
|
||||
{
|
||||
if (m_ptr != other.ptr())
|
||||
release_if_not_null(m_ptr);
|
||||
deref_if_not_null(m_ptr);
|
||||
m_ptr = const_cast<T*>(other.ptr());
|
||||
retain_if_not_null(m_ptr);
|
||||
ref_if_not_null(m_ptr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
RetainPtr& operator=(const T* ptr)
|
||||
{
|
||||
if (m_ptr != ptr)
|
||||
release_if_not_null(m_ptr);
|
||||
deref_if_not_null(m_ptr);
|
||||
m_ptr = const_cast<T*>(ptr);
|
||||
retain_if_not_null(m_ptr);
|
||||
ref_if_not_null(m_ptr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
RetainPtr& operator=(const T& object)
|
||||
{
|
||||
if (m_ptr != &object)
|
||||
release_if_not_null(m_ptr);
|
||||
deref_if_not_null(m_ptr);
|
||||
m_ptr = const_cast<T*>(&object);
|
||||
retain_if_not_null(m_ptr);
|
||||
ref_if_not_null(m_ptr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ public:
|
|||
|
||||
void clear()
|
||||
{
|
||||
release_if_not_null(m_ptr);
|
||||
deref_if_not_null(m_ptr);
|
||||
m_ptr = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,61 +18,61 @@ constexpr auto call_will_be_destroyed_if_present(...) -> FalseType
|
|||
}
|
||||
|
||||
template<class T>
|
||||
constexpr auto call_one_retain_left_if_present(T* object) -> decltype(object->one_retain_left(), TrueType {})
|
||||
constexpr auto call_one_ref_left_if_present(T* object) -> decltype(object->one_ref_left(), TrueType {})
|
||||
{
|
||||
object->one_retain_left();
|
||||
object->one_ref_left();
|
||||
return {};
|
||||
}
|
||||
|
||||
constexpr auto call_one_retain_left_if_present(...) -> FalseType
|
||||
constexpr auto call_one_ref_left_if_present(...) -> FalseType
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
class RetainableBase {
|
||||
class RefCountedBase {
|
||||
public:
|
||||
void retain()
|
||||
void ref()
|
||||
{
|
||||
ASSERT(m_retain_count);
|
||||
++m_retain_count;
|
||||
ASSERT(m_ref_count);
|
||||
++m_ref_count;
|
||||
}
|
||||
|
||||
int retain_count() const
|
||||
int ref_count() const
|
||||
{
|
||||
return m_retain_count;
|
||||
return m_ref_count;
|
||||
}
|
||||
|
||||
protected:
|
||||
RetainableBase() {}
|
||||
~RetainableBase()
|
||||
RefCountedBase() {}
|
||||
~RefCountedBase()
|
||||
{
|
||||
ASSERT(!m_retain_count);
|
||||
ASSERT(!m_ref_count);
|
||||
}
|
||||
|
||||
void release_base()
|
||||
void deref_base()
|
||||
{
|
||||
ASSERT(m_retain_count);
|
||||
--m_retain_count;
|
||||
ASSERT(m_ref_count);
|
||||
--m_ref_count;
|
||||
}
|
||||
|
||||
int m_retain_count { 1 };
|
||||
int m_ref_count { 1 };
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class Retainable : public RetainableBase {
|
||||
class RefCounted : public RefCountedBase {
|
||||
public:
|
||||
void release()
|
||||
void deref()
|
||||
{
|
||||
release_base();
|
||||
if (m_retain_count == 0) {
|
||||
deref_base();
|
||||
if (m_ref_count == 0) {
|
||||
call_will_be_destroyed_if_present(static_cast<T*>(this));
|
||||
delete static_cast<T*>(this);
|
||||
} else if (m_retain_count == 1) {
|
||||
call_one_retain_left_if_present(static_cast<T*>(this));
|
||||
} else if (m_ref_count == 1) {
|
||||
call_one_ref_left_if_present(static_cast<T*>(this));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
using AK::Retainable;
|
||||
using AK::RefCounted;
|
||||
|
|
|
@ -18,17 +18,17 @@
|
|||
namespace AK {
|
||||
|
||||
template<typename T>
|
||||
inline void retain_if_not_null(T* ptr)
|
||||
inline void ref_if_not_null(T* ptr)
|
||||
{
|
||||
if (ptr)
|
||||
ptr->retain();
|
||||
ptr->ref();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void release_if_not_null(T* ptr)
|
||||
inline void deref_if_not_null(T* ptr)
|
||||
{
|
||||
if (ptr)
|
||||
ptr->release();
|
||||
ptr->deref();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -42,14 +42,14 @@ public:
|
|||
Retained(const T& object)
|
||||
: m_ptr(const_cast<T*>(&object))
|
||||
{
|
||||
m_ptr->retain();
|
||||
m_ptr->ref();
|
||||
}
|
||||
template<typename U>
|
||||
RETURN_TYPESTATE(unconsumed)
|
||||
Retained(const U& object)
|
||||
: m_ptr(&const_cast<T&>(static_cast<const T&>(object)))
|
||||
{
|
||||
m_ptr->retain();
|
||||
m_ptr->ref();
|
||||
}
|
||||
RETURN_TYPESTATE(unconsumed)
|
||||
Retained(AdoptTag, T& object)
|
||||
|
@ -85,7 +85,7 @@ public:
|
|||
}
|
||||
~Retained()
|
||||
{
|
||||
release_if_not_null(m_ptr);
|
||||
deref_if_not_null(m_ptr);
|
||||
m_ptr = nullptr;
|
||||
#ifdef SANITIZE_PTRS
|
||||
if constexpr (sizeof(T*) == 8)
|
||||
|
@ -99,7 +99,7 @@ public:
|
|||
Retained& operator=(Retained&& other)
|
||||
{
|
||||
if (this != &other) {
|
||||
release_if_not_null(m_ptr);
|
||||
deref_if_not_null(m_ptr);
|
||||
m_ptr = &other.leak_ref();
|
||||
}
|
||||
return *this;
|
||||
|
@ -110,7 +110,7 @@ public:
|
|||
Retained& operator=(Retained<U>&& other)
|
||||
{
|
||||
if (this != static_cast<void*>(&other)) {
|
||||
release_if_not_null(m_ptr);
|
||||
deref_if_not_null(m_ptr);
|
||||
m_ptr = &other.leak_ref();
|
||||
}
|
||||
return *this;
|
||||
|
@ -120,9 +120,9 @@ public:
|
|||
Retained& operator=(T& object)
|
||||
{
|
||||
if (m_ptr != &object)
|
||||
release_if_not_null(m_ptr);
|
||||
deref_if_not_null(m_ptr);
|
||||
m_ptr = &object;
|
||||
m_ptr->retain();
|
||||
m_ptr->ref();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ enum ShouldChomp {
|
|||
Chomp
|
||||
};
|
||||
|
||||
class StringImpl : public Retainable<StringImpl> {
|
||||
class StringImpl : public RefCounted<StringImpl> {
|
||||
public:
|
||||
static Retained<StringImpl> create_uninitialized(int length, char*& buffer);
|
||||
static RetainPtr<StringImpl> create(const char* cstring, ShouldChomp = NoChomp);
|
||||
|
|
|
@ -12,7 +12,7 @@ template<typename T>
|
|||
class WeakPtr;
|
||||
|
||||
template<typename T>
|
||||
class WeakLink : public Retainable<WeakLink<T>> {
|
||||
class WeakLink : public RefCounted<WeakLink<T>> {
|
||||
friend class Weakable<T>;
|
||||
|
||||
public:
|
||||
|
|
|
@ -11,7 +11,7 @@ class IRCClient;
|
|||
class IRCChannelMemberListModel;
|
||||
class IRCWindow;
|
||||
|
||||
class IRCChannel : public Retainable<IRCChannel> {
|
||||
class IRCChannel : public RefCounted<IRCChannel> {
|
||||
public:
|
||||
static Retained<IRCChannel> create(IRCClient&, const String&);
|
||||
~IRCChannel();
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
class IRCLogBufferModel;
|
||||
|
||||
class IRCLogBuffer : public Retainable<IRCLogBuffer> {
|
||||
class IRCLogBuffer : public RefCounted<IRCLogBuffer> {
|
||||
public:
|
||||
static Retained<IRCLogBuffer> create();
|
||||
~IRCLogBuffer();
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
class IRCClient;
|
||||
class IRCWindow;
|
||||
|
||||
class IRCQuery : public Retainable<IRCQuery> {
|
||||
class IRCQuery : public RefCounted<IRCQuery> {
|
||||
public:
|
||||
static Retained<IRCQuery> create(IRCClient&, const String& name);
|
||||
~IRCQuery();
|
||||
|
|
|
@ -39,7 +39,7 @@ inline void for_each_direction(Callback callback)
|
|||
callback(Direction::DownLeft);
|
||||
}
|
||||
|
||||
class VBWidget : public Retainable<VBWidget>
|
||||
class VBWidget : public RefCounted<VBWidget>
|
||||
, public Weakable<VBWidget> {
|
||||
friend class VBWidgetPropertyModel;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
// FIXME: Support 64-bit DiskOffset
|
||||
typedef dword DiskOffset;
|
||||
|
||||
class DiskDevice : public Retainable<DiskDevice> {
|
||||
class DiskDevice : public RefCounted<DiskDevice> {
|
||||
public:
|
||||
virtual ~DiskDevice();
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class Region;
|
|||
// - Called by mmap() when userspace wants to memory-map this File somewhere.
|
||||
// - Should create a Region in the Process and return it if successful.
|
||||
|
||||
class File : public Retainable<File> {
|
||||
class File : public RefCounted<File> {
|
||||
public:
|
||||
virtual ~File();
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ class VFS;
|
|||
|
||||
// FIXME: Custody needs some locking.
|
||||
|
||||
class Custody : public Retainable<Custody> {
|
||||
class Custody : public RefCounted<Custody> {
|
||||
public:
|
||||
static Custody* get_if_cached(Custody* parent, const String& name);
|
||||
static Retained<Custody> get_or_create(Custody* parent, const String& name, Inode&);
|
||||
|
|
|
@ -1232,7 +1232,7 @@ InodeIdentifier Ext2FSInode::lookup(StringView name)
|
|||
return {};
|
||||
}
|
||||
|
||||
void Ext2FSInode::one_retain_left()
|
||||
void Ext2FSInode::one_ref_left()
|
||||
{
|
||||
// FIXME: I would like to not live forever, but uncached Ext2FS is fucking painful right now.
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
bool is_symlink() const { return ::is_symlink(m_raw_inode.i_mode); }
|
||||
|
||||
// ^Inode (Retainable magic)
|
||||
virtual void one_retain_left() override;
|
||||
virtual void one_ref_left() override;
|
||||
|
||||
private:
|
||||
// ^Inode
|
||||
|
|
|
@ -19,7 +19,7 @@ class Region;
|
|||
class CharacterDevice;
|
||||
class SharedMemory;
|
||||
|
||||
class FileDescription : public Retainable<FileDescription> {
|
||||
class FileDescription : public RefCounted<FileDescription> {
|
||||
public:
|
||||
static Retained<FileDescription> create(RetainPtr<Custody>&&);
|
||||
static Retained<FileDescription> create(RetainPtr<File>&&, SocketRole = SocketRole::None);
|
||||
|
|
|
@ -23,7 +23,7 @@ class FileDescription;
|
|||
class LocalSocket;
|
||||
class VMObject;
|
||||
|
||||
class FS : public Retainable<FS> {
|
||||
class FS : public RefCounted<FS> {
|
||||
friend class Inode;
|
||||
|
||||
public:
|
||||
|
|
|
@ -14,14 +14,14 @@ class FileDescription;
|
|||
class LocalSocket;
|
||||
class VMObject;
|
||||
|
||||
class Inode : public Retainable<Inode> {
|
||||
class Inode : public RefCounted<Inode> {
|
||||
friend class VFS;
|
||||
friend class FS;
|
||||
|
||||
public:
|
||||
virtual ~Inode();
|
||||
|
||||
virtual void one_retain_left() {}
|
||||
virtual void one_ref_left() {}
|
||||
|
||||
FS& fs() { return m_fs; }
|
||||
const FS& fs() const { return m_fs; }
|
||||
|
|
|
@ -293,13 +293,13 @@ ByteBuffer procfs$pid_vmo(InodeIdentifier identifier)
|
|||
region->vmo().is_anonymous() ? "anonymous" : "file-backed",
|
||||
region->vmo().name().characters(),
|
||||
®ion->vmo(),
|
||||
region->vmo().retain_count());
|
||||
region->vmo().ref_count());
|
||||
for (size_t i = 0; i < region->vmo().page_count(); ++i) {
|
||||
auto& physical_page = region->vmo().physical_pages()[i];
|
||||
builder.appendf("P%x%s(%u) ",
|
||||
physical_page ? physical_page->paddr().get() : 0,
|
||||
region->should_cow(i) ? "!" : "",
|
||||
physical_page ? physical_page->retain_count() : 0);
|
||||
physical_page ? physical_page->ref_count() : 0);
|
||||
}
|
||||
builder.appendf("\n");
|
||||
}
|
||||
|
@ -406,7 +406,7 @@ ByteBuffer procfs$mm(InodeIdentifier)
|
|||
builder.appendf("VMO: %p %s(%u): p:%4u %s\n",
|
||||
vmo,
|
||||
vmo->is_anonymous() ? "anon" : "file",
|
||||
vmo->retain_count(),
|
||||
vmo->ref_count(),
|
||||
vmo->page_count(),
|
||||
vmo->name().characters());
|
||||
}
|
||||
|
@ -615,7 +615,7 @@ ByteBuffer procfs$inodes(InodeIdentifier)
|
|||
StringBuilder builder;
|
||||
for (auto it : all_inodes()) {
|
||||
RetainPtr<Inode> inode = *it;
|
||||
builder.appendf("Inode{K%x} %02u:%08u (%u)\n", inode.ptr(), inode->fsid(), inode->index(), inode->retain_count());
|
||||
builder.appendf("Inode{K%x} %02u:%08u (%u)\n", inode.ptr(), inode->fsid(), inode->index(), inode->ref_count());
|
||||
}
|
||||
return builder.to_byte_buffer();
|
||||
}
|
||||
|
|
|
@ -2032,7 +2032,7 @@ size_t Process::amount_shared() const
|
|||
{
|
||||
// FIXME: This will double count if multiple regions use the same physical page.
|
||||
// FIXME: It doesn't work at the moment, since it relies on PhysicalPage retain counts,
|
||||
// and each PhysicalPage is only retained by its VMObject. This needs to be refactored
|
||||
// and each PhysicalPage is only reffed by its VMObject. This needs to be refactored
|
||||
// so that every Region contributes +1 retain to each of its PhysicalPages.
|
||||
size_t amount = 0;
|
||||
for (auto& region : m_regions) {
|
||||
|
@ -2417,8 +2417,8 @@ struct SharedBuffer {
|
|||
|
||||
pid_t pid1() const { return m_pid1; }
|
||||
pid_t pid2() const { return m_pid2; }
|
||||
unsigned pid1_retain_count() const { return m_pid1_retain_count; }
|
||||
unsigned pid2_retain_count() const { return m_pid2_retain_count; }
|
||||
unsigned pid1_ref_count() const { return m_pid1_retain_count; }
|
||||
unsigned pid2_ref_count() const { return m_pid2_retain_count; }
|
||||
size_t size() const { return m_vmo->size(); }
|
||||
void destroy_if_unused();
|
||||
|
||||
|
|
|
@ -61,11 +61,11 @@ bool MasterPTY::can_write(FileDescription&) const
|
|||
void MasterPTY::notify_slave_closed(Badge<SlavePTY>)
|
||||
{
|
||||
#ifdef MASTERPTY_DEBUG
|
||||
dbgprintf("MasterPTY(%u): slave closed, my retains: %u, slave retains: %u\n", m_index, retain_count(), m_slave->retain_count());
|
||||
dbgprintf("MasterPTY(%u): slave closed, my retains: %u, slave retains: %u\n", m_index, ref_count(), m_slave->ref_count());
|
||||
#endif
|
||||
// +1 retain for my MasterPTY::m_slave
|
||||
// +1 retain for FileDescription::m_device
|
||||
if (m_slave->retain_count() == 2)
|
||||
if (m_slave->ref_count() == 2)
|
||||
m_slave = nullptr;
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ bool MasterPTY::can_write_from_slave() const
|
|||
|
||||
void MasterPTY::close()
|
||||
{
|
||||
if (retain_count() == 2) {
|
||||
if (ref_count() == 2) {
|
||||
InterruptDisabler disabler;
|
||||
// After the closing FileDescription dies, slave is the only thing keeping me alive.
|
||||
// From this point, let's consider ourselves closed.
|
||||
|
|
|
@ -324,7 +324,7 @@ bool MemoryManager::copy_on_write(Region& region, unsigned page_index_in_region)
|
|||
{
|
||||
ASSERT_INTERRUPTS_DISABLED();
|
||||
auto& vmo = region.vmo();
|
||||
if (vmo.physical_pages()[page_index_in_region]->retain_count() == 1) {
|
||||
if (vmo.physical_pages()[page_index_in_region]->ref_count() == 1) {
|
||||
#ifdef PAGE_FAULT_DEBUG
|
||||
dbgprintf(" >> It's a COW page but nobody is sharing it anymore. Remap r/w\n");
|
||||
#endif
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <Kernel/VM/PhysicalPage.h>
|
||||
#include <Kernel/VM/RangeAllocator.h>
|
||||
|
||||
class PageDirectory : public Retainable<PageDirectory> {
|
||||
class PageDirectory : public RefCounted<PageDirectory> {
|
||||
friend class MemoryManager;
|
||||
|
||||
public:
|
||||
|
|
|
@ -12,13 +12,13 @@ class PhysicalPage {
|
|||
public:
|
||||
PhysicalAddress paddr() const { return m_paddr; }
|
||||
|
||||
void retain()
|
||||
void ref()
|
||||
{
|
||||
ASSERT(m_retain_count);
|
||||
++m_retain_count;
|
||||
}
|
||||
|
||||
void release()
|
||||
void deref()
|
||||
{
|
||||
ASSERT(m_retain_count);
|
||||
if (!--m_retain_count) {
|
||||
|
@ -30,7 +30,7 @@ public:
|
|||
|
||||
static Retained<PhysicalPage> create(PhysicalAddress, bool supervisor, bool may_return_to_freelist = true);
|
||||
|
||||
word retain_count() const { return m_retain_count; }
|
||||
word ref_count() const { return m_retain_count; }
|
||||
|
||||
private:
|
||||
PhysicalPage(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist = true);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <Kernel/PhysicalAddress.h>
|
||||
#include <Kernel/VM/PhysicalPage.h>
|
||||
|
||||
class PhysicalRegion : public Retainable<PhysicalRegion> {
|
||||
class PhysicalRegion : public RefCounted<PhysicalRegion> {
|
||||
AK_MAKE_ETERNAL
|
||||
|
||||
public:
|
||||
|
|
|
@ -129,7 +129,7 @@ size_t Region::amount_shared() const
|
|||
size_t bytes = 0;
|
||||
for (size_t i = 0; i < page_count(); ++i) {
|
||||
auto& physical_page = m_vmo->physical_pages()[first_page_index() + i];
|
||||
if (physical_page && physical_page->retain_count() > 1)
|
||||
if (physical_page && physical_page->ref_count() > 1)
|
||||
bytes += PAGE_SIZE;
|
||||
}
|
||||
return bytes;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
class Inode;
|
||||
class VMObject;
|
||||
|
||||
class Region : public Retainable<Region> {
|
||||
class Region : public RefCounted<Region> {
|
||||
friend class MemoryManager;
|
||||
|
||||
public:
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
class Inode;
|
||||
class PhysicalPage;
|
||||
|
||||
class VMObject : public Retainable<VMObject>
|
||||
class VMObject : public RefCounted<VMObject>
|
||||
, public Weakable<VMObject> {
|
||||
friend class MemoryManager;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <AK/RetainPtr.h>
|
||||
#include <AK/Retainable.h>
|
||||
|
||||
class SharedBuffer : public Retainable<SharedBuffer> {
|
||||
class SharedBuffer : public RefCounted<SharedBuffer> {
|
||||
public:
|
||||
static RetainPtr<SharedBuffer> create(pid_t peer, int);
|
||||
static RetainPtr<SharedBuffer> create_from_shared_buffer_id(int);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <SharedGraphics/Color.h>
|
||||
|
||||
class CConfigFile : public Retainable<CConfigFile> {
|
||||
class CConfigFile : public RefCounted<CConfigFile> {
|
||||
public:
|
||||
static Retained<CConfigFile> get_for_app(const String& app_name);
|
||||
static Retained<CConfigFile> get_for_system(const String& app_name);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Retainable.h>
|
||||
|
||||
class CNetworkResponse : public Retainable<CNetworkResponse> {
|
||||
class CNetworkResponse : public RefCounted<CNetworkResponse> {
|
||||
public:
|
||||
virtual ~CNetworkResponse();
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ class GButton;
|
|||
class GMenuItem;
|
||||
class GWidget;
|
||||
|
||||
class GAction : public Retainable<GAction>
|
||||
class GAction : public RefCounted<GAction>
|
||||
, public Weakable<GAction> {
|
||||
public:
|
||||
enum class ShortcutScope {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <AK/HashMap.h>
|
||||
#include <SharedGraphics/GraphicsBitmap.h>
|
||||
|
||||
class GIconImpl : public Retainable<GIconImpl> {
|
||||
class GIconImpl : public RefCounted<GIconImpl> {
|
||||
public:
|
||||
static Retained<GIconImpl> create() { return adopt(*new GIconImpl); }
|
||||
~GIconImpl() {}
|
||||
|
|
|
@ -39,7 +39,7 @@ private:
|
|||
GModelIndex m_index;
|
||||
};
|
||||
|
||||
class GModel : public Retainable<GModel> {
|
||||
class GModel : public RefCounted<GModel> {
|
||||
public:
|
||||
struct ColumnMetadata {
|
||||
int preferred_width { 0 };
|
||||
|
|
|
@ -14,13 +14,13 @@ void GVariant::clear()
|
|||
{
|
||||
switch (m_type) {
|
||||
case Type::String:
|
||||
AK::release_if_not_null(m_value.as_string);
|
||||
AK::deref_if_not_null(m_value.as_string);
|
||||
break;
|
||||
case Type::Bitmap:
|
||||
AK::release_if_not_null(m_value.as_bitmap);
|
||||
AK::deref_if_not_null(m_value.as_bitmap);
|
||||
break;
|
||||
case Type::Icon:
|
||||
AK::release_if_not_null(m_value.as_icon);
|
||||
AK::deref_if_not_null(m_value.as_icon);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -51,21 +51,21 @@ GVariant::GVariant(const String& value)
|
|||
: m_type(Type::String)
|
||||
{
|
||||
m_value.as_string = const_cast<StringImpl*>(value.impl());
|
||||
AK::retain_if_not_null(m_value.as_string);
|
||||
AK::ref_if_not_null(m_value.as_string);
|
||||
}
|
||||
|
||||
GVariant::GVariant(const GraphicsBitmap& value)
|
||||
: m_type(Type::Bitmap)
|
||||
{
|
||||
m_value.as_bitmap = const_cast<GraphicsBitmap*>(&value);
|
||||
AK::retain_if_not_null(m_value.as_bitmap);
|
||||
AK::ref_if_not_null(m_value.as_bitmap);
|
||||
}
|
||||
|
||||
GVariant::GVariant(const GIcon& value)
|
||||
: m_type(Type::Icon)
|
||||
{
|
||||
m_value.as_icon = &const_cast<GIconImpl&>(value.impl());
|
||||
AK::retain_if_not_null(m_value.as_icon);
|
||||
AK::ref_if_not_null(m_value.as_icon);
|
||||
}
|
||||
|
||||
GVariant::GVariant(Color color)
|
||||
|
@ -133,15 +133,15 @@ void GVariant::copy_from(const GVariant& other)
|
|||
break;
|
||||
case Type::String:
|
||||
m_value.as_string = other.m_value.as_string;
|
||||
AK::retain_if_not_null(m_value.as_bitmap);
|
||||
AK::ref_if_not_null(m_value.as_bitmap);
|
||||
break;
|
||||
case Type::Bitmap:
|
||||
m_value.as_bitmap = other.m_value.as_bitmap;
|
||||
AK::retain_if_not_null(m_value.as_bitmap);
|
||||
AK::ref_if_not_null(m_value.as_bitmap);
|
||||
break;
|
||||
case Type::Icon:
|
||||
m_value.as_icon = other.m_value.as_icon;
|
||||
AK::retain_if_not_null(m_value.as_icon);
|
||||
AK::ref_if_not_null(m_value.as_icon);
|
||||
break;
|
||||
case Type::Color:
|
||||
m_value.as_color = other.m_value.as_color;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <AK/Retainable.h>
|
||||
|
||||
class StyleValue : public Retainable<StyleValue> {
|
||||
class StyleValue : public RefCounted<StyleValue> {
|
||||
public:
|
||||
virtual ~StyleValue();
|
||||
|
||||
|
|
|
@ -10,13 +10,13 @@ Node::~Node()
|
|||
{
|
||||
}
|
||||
|
||||
void Node::retain()
|
||||
void Node::ref()
|
||||
{
|
||||
ASSERT(m_retain_count);
|
||||
++m_retain_count;
|
||||
}
|
||||
|
||||
void Node::release()
|
||||
void Node::deref()
|
||||
{
|
||||
ASSERT(m_retain_count);
|
||||
if (!--m_retain_count)
|
||||
|
|
|
@ -18,9 +18,9 @@ class Node {
|
|||
public:
|
||||
virtual ~Node();
|
||||
|
||||
void retain();
|
||||
void release();
|
||||
int retain_count() const { return m_retain_count; }
|
||||
void ref();
|
||||
void deref();
|
||||
int ref_count() const { return m_retain_count; }
|
||||
|
||||
ParentNode* parent_node() { return m_parent_node; }
|
||||
const ParentNode* parent_node() const { return m_parent_node; }
|
||||
|
|
|
@ -9,13 +9,13 @@ LayoutNode::~LayoutNode()
|
|||
{
|
||||
}
|
||||
|
||||
void LayoutNode::retain()
|
||||
void LayoutNode::ref()
|
||||
{
|
||||
ASSERT(m_retain_count);
|
||||
++m_retain_count;
|
||||
}
|
||||
|
||||
void LayoutNode::release()
|
||||
void LayoutNode::deref()
|
||||
{
|
||||
ASSERT(m_retain_count);
|
||||
if (!--m_retain_count)
|
||||
|
|
|
@ -11,9 +11,9 @@ class LayoutNode {
|
|||
public:
|
||||
virtual ~LayoutNode();
|
||||
|
||||
void retain();
|
||||
void release();
|
||||
int retain_count() const { return m_retain_count; }
|
||||
void ref();
|
||||
void deref();
|
||||
int ref_count() const { return m_retain_count; }
|
||||
|
||||
const Rect& rect() const { return m_rect; }
|
||||
Rect& rect() { return m_rect; }
|
||||
|
|
|
@ -12,7 +12,7 @@ enum class WSStandardCursor {
|
|||
ResizeDiagonalBLTR,
|
||||
};
|
||||
|
||||
class WSCursor : public Retainable<WSCursor> {
|
||||
class WSCursor : public RefCounted<WSCursor> {
|
||||
public:
|
||||
static Retained<WSCursor> create(Retained<GraphicsBitmap>&&, const Point& hotspot);
|
||||
static Retained<WSCursor> create(Retained<GraphicsBitmap>&&);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <AK/RetainPtr.h>
|
||||
#include <AK/Retainable.h>
|
||||
|
||||
class CharacterBitmap : public Retainable<CharacterBitmap> {
|
||||
class CharacterBitmap : public RefCounted<CharacterBitmap> {
|
||||
public:
|
||||
static Retained<CharacterBitmap> create_from_ascii(const char* asciiData, unsigned width, unsigned height);
|
||||
~CharacterBitmap();
|
||||
|
|
|
@ -40,7 +40,7 @@ private:
|
|||
Size m_size;
|
||||
};
|
||||
|
||||
class Font : public Retainable<Font> {
|
||||
class Font : public RefCounted<Font> {
|
||||
public:
|
||||
static Font& default_font();
|
||||
static Font& default_bold_font();
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <AK/StringView.h>
|
||||
#include <SharedBuffer.h>
|
||||
|
||||
class GraphicsBitmap : public Retainable<GraphicsBitmap> {
|
||||
class GraphicsBitmap : public RefCounted<GraphicsBitmap> {
|
||||
public:
|
||||
enum class Format {
|
||||
Invalid,
|
||||
|
|
Loading…
Add table
Reference in a new issue