Kernel: Simplify Process factory functions

- Instead of taking the first new thread as an out-parameter, we now
  bundle the process and its first thread in a struct and use that
  as the return value.

- Make all Process factory functions return ErrorOr. Use this to convert
  some places to more TRY().

- Drop the "try_" prefix on Process factory functions.
This commit is contained in:
Andreas Kling 2023-04-02 19:25:36 +02:00
parent 65438d8a85
commit a098266ff5
Notes: sideshowbarker 2024-07-17 05:05:51 +09:00
12 changed files with 319 additions and 78 deletions

View file

@ -24,11 +24,10 @@ UNMAP_AFTER_INIT void WorkQueue::initialize()
UNMAP_AFTER_INIT WorkQueue::WorkQueue(StringView name)
{
LockRefPtr<Thread> thread;
auto name_kstring = KString::try_create(name);
if (name_kstring.is_error())
TODO();
(void)Process::create_kernel_process(thread, name_kstring.release_value(), [this] {
auto [_, thread] = Process::create_kernel_process(name_kstring.release_value(), [this] {
#if ARCH(AARCH64)
// FIXME: This function expects to be executed with interrupts disabled, however on
// aarch64 we spawn (kernel) threads with interrupts enabled, so we need to disable them.
@ -52,9 +51,8 @@ UNMAP_AFTER_INIT WorkQueue::WorkQueue(StringView name)
}
[[maybe_unused]] auto result = m_wait_queue.wait_on({});
}
});
// If we can't create the thread we're in trouble...
m_thread = thread.release_nonnull();
}).release_value_but_fixme_should_propagate_errors();
m_thread = move(thread);
}
void WorkQueue::do_queue(WorkItem& item)