pub struct KernelThreads {
pub starnix_process: Process,
/* private fields */
}Expand description
The threads that the kernel runs internally.
These threads run in the main starnix process and outlive any specific userspace process.
Fields§
§starnix_process: ProcessThe main starnix process. This process is used to create new processes when using the restricted executor.
Implementations§
Source§impl KernelThreads
impl KernelThreads
Sourcepub fn new(kernel: Weak<Kernel>) -> Self
pub fn new(kernel: Weak<Kernel>) -> Self
Create a KernelThreads object for the given Kernel.
Must be called in the initial Starnix process on a thread with an async executor. This function captures the async executor for this thread for use with spawned futures.
Used during kernel boot.
Sourcepub fn init(&self, system_task: CurrentTask) -> Result<(), Errno>
pub fn init(&self, system_task: CurrentTask) -> Result<(), Errno>
Initialize this object with the system task that will be used for spawned threads.
This function must be called before this object is used to spawn threads.
Sourcepub fn spawn_future(&self, future: impl AsyncFnOnce() + Send + 'static)
pub fn spawn_future(&self, future: impl AsyncFnOnce() + Send + 'static)
Spawn an async task in the main async executor to await the given future.
Use this function to run async tasks in the background. These tasks cannot block or else they will starve the main async executor.
Prefer this function to spawn for non-blocking work.
Sourcepub fn spawner(&self) -> &DynamicThreadSpawner
pub fn spawner(&self) -> &DynamicThreadSpawner
The dynamic thread spawner used to spawn threads.
To spawn a thread in this thread pool, use spawn().
Sourcepub fn system_task(&self) -> &CurrentTask
pub fn system_task(&self) -> &CurrentTask
Access the CurrentTask for the kernel main thread.
This function can only be called from the kernel main thread itself.
Sourcepub fn unlocked_for_async(&self) -> RefMut<'_, Locked<Unlocked>>
pub fn unlocked_for_async(&self) -> RefMut<'_, Locked<Unlocked>>
Access the Unlocked state.
This function is intended for limited use in async contexts and can only be called from the kernel main thread.
Sourcepub fn system_thread_group(&self) -> Arc<ThreadGroup>
pub fn system_thread_group(&self) -> Arc<ThreadGroup>
Access the ThreadGroup for the system tasks.
This function can be safely called from anywhere as soon as KernelThreads::init has been
called.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for KernelThreads
impl !RefUnwindSafe for KernelThreads
impl Send for KernelThreads
impl Sync for KernelThreads
impl Unpin for KernelThreads
impl !UnwindSafe for KernelThreads
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
T to [Self]Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more