1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:18:12 +00:00

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
12 changed files with 319 additions and 78 deletions

View file

@ -585,22 +585,20 @@ size_t UHCIController::poll_transfer_queue(QueueHead& transfer_queue)
ErrorOr<void> UHCIController::spawn_port_process()
{
LockRefPtr<Thread> usb_hotplug_thread;
(void)Process::create_kernel_process(usb_hotplug_thread, TRY(KString::try_create("UHCI Hot Plug Task"sv)), [&] {
TRY(Process::create_kernel_process(TRY(KString::try_create("UHCI Hot Plug Task"sv)), [&] {
for (;;) {
if (m_root_hub)
m_root_hub->check_for_port_updates();
(void)Thread::current()->sleep(Time::from_seconds(1));
}
});
}));
return {};
}
ErrorOr<void> UHCIController::spawn_async_poll_process()
{
LockRefPtr<Thread> async_poll_thread;
(void)Process::create_kernel_process(async_poll_thread, TRY(KString::try_create("UHCI Async Poll Task"sv)), [&] {
TRY(Process::create_kernel_process(TRY(KString::try_create("UHCI Async Poll Task"sv)), [&] {
u16 poll_interval_ms = 1024;
for (;;) {
{
@ -620,7 +618,7 @@ ErrorOr<void> UHCIController::spawn_async_poll_process()
}
(void)Thread::current()->sleep(Time::from_milliseconds(poll_interval_ms));
}
});
}));
return {};
}