mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:17:35 +00:00
AK: Rename Retainable => RefCounted.
(And various related renames that go along with it.)
This commit is contained in:
parent
ef1bfcb9d8
commit
77b9fa89dd
45 changed files with 118 additions and 118 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue