Kernel: Rename RefCounted -> RefPtr and implement RefCounted
This commit is contained in:
@@ -253,12 +253,12 @@ namespace Kernel
|
||||
return data_buffer;
|
||||
}
|
||||
|
||||
BAN::ErrorOr<BAN::RefCounted<Inode>> Ext2Inode::directory_find(BAN::StringView file_name)
|
||||
BAN::ErrorOr<BAN::RefPtr<Inode>> Ext2Inode::directory_find(BAN::StringView file_name)
|
||||
{
|
||||
if (!ifdir())
|
||||
return BAN::Error::from_errno(ENOTDIR);
|
||||
|
||||
BAN::RefCounted<Inode> result;
|
||||
BAN::RefPtr<Inode> result;
|
||||
BAN::Function<BAN::ErrorOr<bool>(const BAN::Vector<uint8_t>&)> function(
|
||||
[&](const BAN::Vector<uint8_t>& block_data) -> BAN::ErrorOr<bool>
|
||||
{
|
||||
@@ -273,7 +273,7 @@ namespace Kernel
|
||||
Ext2Inode* inode = new Ext2Inode(m_fs, TRY(m_fs->read_inode(entry->inode)), entry_name);
|
||||
if (inode == nullptr)
|
||||
return BAN::Error::from_errno(ENOMEM);
|
||||
result = TRY(BAN::RefCounted<Inode>::adopt(inode));
|
||||
result = BAN::RefPtr<Inode>::adopt(inode);
|
||||
return false;
|
||||
}
|
||||
entry_addr += entry->rec_len;
|
||||
@@ -288,12 +288,12 @@ namespace Kernel
|
||||
return BAN::Error::from_errno(ENOENT);
|
||||
}
|
||||
|
||||
BAN::ErrorOr<BAN::Vector<BAN::RefCounted<Inode>>> Ext2Inode::directory_inodes()
|
||||
BAN::ErrorOr<BAN::Vector<BAN::RefPtr<Inode>>> Ext2Inode::directory_inodes()
|
||||
{
|
||||
if (!ifdir())
|
||||
return BAN::Error::from_errno(ENOTDIR);
|
||||
|
||||
BAN::Vector<BAN::RefCounted<Inode>> inodes;
|
||||
BAN::Vector<BAN::RefPtr<Inode>> inodes;
|
||||
BAN::Function<BAN::ErrorOr<bool>(const BAN::Vector<uint8_t>&)> function(
|
||||
[&](const BAN::Vector<uint8_t>& block_data) -> BAN::ErrorOr<bool>
|
||||
{
|
||||
@@ -310,7 +310,7 @@ namespace Kernel
|
||||
Ext2Inode* inode = new Ext2Inode(m_fs, BAN::move(current_inode), entry_name);
|
||||
if (inode == nullptr)
|
||||
return BAN::Error::from_errno(ENOMEM);
|
||||
TRY(inodes.push_back(TRY(BAN::RefCounted<Inode>::adopt(inode))));
|
||||
TRY(inodes.push_back(BAN::RefPtr<Inode>::adopt(inode)));
|
||||
}
|
||||
entry_addr += entry->rec_len;
|
||||
}
|
||||
@@ -431,7 +431,7 @@ namespace Kernel
|
||||
Ext2Inode* root_inode = new Ext2Inode(this, TRY(read_inode(Ext2::Enum::ROOT_INO)), "");
|
||||
if (root_inode == nullptr)
|
||||
return BAN::Error::from_errno(ENOMEM);
|
||||
m_root_inode = TRY(BAN::RefCounted<Inode>::adopt(root_inode));
|
||||
m_root_inode = BAN::RefPtr<Inode>::adopt(root_inode);
|
||||
|
||||
#if EXT2_DEBUG_PRINT
|
||||
dprintln("root inode:");
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Kernel
|
||||
return BAN::Error::from_string("Could not locate root partition");
|
||||
}
|
||||
|
||||
BAN::ErrorOr<BAN::RefCounted<Inode>> VirtualFileSystem::from_absolute_path(BAN::StringView path)
|
||||
BAN::ErrorOr<BAN::RefPtr<Inode>> VirtualFileSystem::from_absolute_path(BAN::StringView path)
|
||||
{
|
||||
if (path.front() != '/')
|
||||
return BAN::Error::from_string("Path must be an absolute path");
|
||||
|
||||
@@ -46,9 +46,9 @@ namespace Kernel
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
Thread& Scheduler::current_thread()
|
||||
BAN::RefPtr<Thread> Scheduler::current_thread()
|
||||
{
|
||||
return m_current_thread ? *m_current_thread->thread : *m_idle_thread;
|
||||
return m_current_thread ? m_current_thread->thread : m_idle_thread;
|
||||
}
|
||||
|
||||
void Scheduler::reschedule()
|
||||
@@ -147,9 +147,9 @@ namespace Kernel
|
||||
}
|
||||
read_rsp(rsp);
|
||||
|
||||
auto& current = current_thread();
|
||||
current.set_rip(rip);
|
||||
current.set_rsp(rsp);
|
||||
auto current = current_thread();
|
||||
current->set_rip(rip);
|
||||
current->set_rsp(rsp);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace Kernel
|
||||
{
|
||||
VERIFY_CLI();
|
||||
|
||||
auto& current = current_thread();
|
||||
auto& current = *current_thread();
|
||||
|
||||
if (current.started())
|
||||
{
|
||||
|
||||
@@ -182,7 +182,7 @@ argument_done:
|
||||
|
||||
s_thread_spinlock.lock();
|
||||
|
||||
MUST(Scheduler::get().add_thread(MUST(Thread::create(
|
||||
auto thread_or_error = Thread::create(
|
||||
[this, &arguments]
|
||||
{
|
||||
auto args = arguments;
|
||||
@@ -191,7 +191,11 @@ argument_done:
|
||||
PIT::sleep(5000);
|
||||
process_command(args);
|
||||
}
|
||||
))));
|
||||
);
|
||||
if (thread_or_error.is_error())
|
||||
return TTY_PRINTLN("{}", thread_or_error.error());
|
||||
|
||||
MUST(Scheduler::get().add_thread(thread));
|
||||
|
||||
while (s_thread_spinlock.is_locked());
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ namespace Kernel
|
||||
}
|
||||
|
||||
|
||||
BAN::ErrorOr<BAN::RefCounted<Thread>> Thread::create(const BAN::Function<void()>& function)
|
||||
BAN::ErrorOr<BAN::RefPtr<Thread>> Thread::create(const BAN::Function<void()>& function)
|
||||
{
|
||||
return BAN::RefCounted<Thread>::create(function);
|
||||
return BAN::RefPtr<Thread>::create(function);
|
||||
}
|
||||
|
||||
Thread::Thread(const BAN::Function<void()>& function)
|
||||
|
||||
Reference in New Issue
Block a user