mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-19 20:46:35 +00:00
Rename (Posix)ThreadExt
to As(Posix)Thread
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
9233d1cdbb
commit
e6c613f538
@ -9,7 +9,7 @@ use ostd::{
|
||||
};
|
||||
|
||||
use super::{
|
||||
posix_thread::{thread_table, PosixThread, PosixThreadBuilder, PosixThreadExt, ThreadName},
|
||||
posix_thread::{thread_table, AsPosixThread, PosixThread, PosixThreadBuilder, ThreadName},
|
||||
process_table,
|
||||
process_vm::ProcessVm,
|
||||
signal::{constants::SIGCHLD, sig_disposition::SigDispositions, sig_num::SigNum},
|
||||
@ -21,7 +21,7 @@ use crate::{
|
||||
get_current_userspace,
|
||||
prelude::*,
|
||||
process::posix_thread::allocate_posix_tid,
|
||||
thread::{ThreadExt, Tid},
|
||||
thread::{AsThread, Tid},
|
||||
};
|
||||
|
||||
bitflags! {
|
||||
|
@ -4,10 +4,10 @@ use super::{process_table, Pid, Process, TermStatus};
|
||||
use crate::{
|
||||
prelude::*,
|
||||
process::{
|
||||
posix_thread::{do_exit, PosixThreadExt},
|
||||
posix_thread::{do_exit, AsPosixThread},
|
||||
signal::signals::kernel::KernelSignal,
|
||||
},
|
||||
thread::ThreadExt,
|
||||
thread::AsThread,
|
||||
};
|
||||
|
||||
pub fn do_exit_group(term_status: TermStatus) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use super::{
|
||||
posix_thread::{thread_table, PosixThreadExt},
|
||||
posix_thread::{thread_table, AsPosixThread},
|
||||
process_table,
|
||||
signal::{
|
||||
constants::SIGCONT,
|
||||
|
@ -22,7 +22,7 @@ use crate::{
|
||||
events::Observer,
|
||||
prelude::*,
|
||||
process::signal::constants::SIGCONT,
|
||||
thread::{Thread, ThreadExt, Tid},
|
||||
thread::{AsThread, Thread, Tid},
|
||||
time::{clocks::ProfClock, Timer, TimerManager},
|
||||
};
|
||||
|
||||
@ -37,7 +37,7 @@ pub mod thread_table;
|
||||
pub use builder::PosixThreadBuilder;
|
||||
pub use exit::do_exit;
|
||||
pub use name::{ThreadName, MAX_THREAD_NAME_LEN};
|
||||
pub use posix_thread_ext::{create_posix_task_from_executable, PosixThreadExt};
|
||||
pub use posix_thread_ext::{create_posix_task_from_executable, AsPosixThread};
|
||||
pub use robust_list::RobustListHead;
|
||||
|
||||
pub struct PosixThread {
|
||||
|
@ -11,22 +11,22 @@ use crate::{
|
||||
fs::fs_resolver::{FsPath, FsResolver, AT_FDCWD},
|
||||
prelude::*,
|
||||
process::{process_vm::ProcessVm, program_loader::load_program_to_vm, Credentials, Process},
|
||||
thread::{Thread, ThreadExt, Tid},
|
||||
thread::{AsThread, Thread, Tid},
|
||||
};
|
||||
|
||||
/// An extension trait for some [`PosixThread`]-like types.
|
||||
pub trait PosixThreadExt {
|
||||
/// A trait to provide the `as_posix_thread` method for tasks and threads.
|
||||
pub trait AsPosixThread {
|
||||
/// Returns the associated [`PosixThread`].
|
||||
fn as_posix_thread(&self) -> Option<&PosixThread>;
|
||||
}
|
||||
|
||||
impl PosixThreadExt for Thread {
|
||||
impl AsPosixThread for Thread {
|
||||
fn as_posix_thread(&self) -> Option<&PosixThread> {
|
||||
self.data().downcast_ref::<PosixThread>()
|
||||
}
|
||||
}
|
||||
|
||||
impl PosixThreadExt for Task {
|
||||
impl AsPosixThread for Task {
|
||||
fn as_posix_thread(&self) -> Option<&PosixThread> {
|
||||
self.as_thread()?.as_posix_thread()
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use super::{Thread, Tid};
|
||||
use crate::{prelude::*, process::posix_thread::PosixThreadExt};
|
||||
use crate::{prelude::*, process::posix_thread::AsPosixThread};
|
||||
|
||||
static THREAD_TABLE: SpinLock<BTreeMap<Tid, Arc<Thread>>> = SpinLock::new(BTreeMap::new());
|
||||
|
||||
|
@ -4,7 +4,7 @@ use core::sync::atomic::{AtomicU32, Ordering};
|
||||
|
||||
use self::timer_manager::PosixTimerManager;
|
||||
use super::{
|
||||
posix_thread::{allocate_posix_tid, PosixThreadExt},
|
||||
posix_thread::{allocate_posix_tid, AsPosixThread},
|
||||
process_table,
|
||||
process_vm::{Heap, InitStackReader, ProcessVm},
|
||||
rlimit::ResourceLimits,
|
||||
@ -21,7 +21,7 @@ use crate::{
|
||||
fs::{file_table::FileTable, fs_resolver::FsResolver, utils::FileCreationMask},
|
||||
prelude::*,
|
||||
sched::priority::{AtomicNice, Nice},
|
||||
thread::{Thread, ThreadExt},
|
||||
thread::{AsThread, Thread},
|
||||
time::clocks::ProfClock,
|
||||
vm::vmar::Vmar,
|
||||
};
|
||||
|
@ -17,7 +17,7 @@ use ostd::{
|
||||
use super::Process;
|
||||
use crate::{
|
||||
process::{
|
||||
posix_thread::PosixThreadExt,
|
||||
posix_thread::AsPosixThread,
|
||||
signal::{constants::SIGALRM, signals::kernel::KernelSignal},
|
||||
},
|
||||
thread::{
|
||||
|
@ -7,8 +7,8 @@ use ostd::sync::{WaitQueue, Waiter};
|
||||
use super::sig_mask::SigMask;
|
||||
use crate::{
|
||||
prelude::*,
|
||||
process::posix_thread::PosixThreadExt,
|
||||
thread::ThreadExt,
|
||||
process::posix_thread::AsPosixThread,
|
||||
thread::AsThread,
|
||||
time::wait::{ManagedTimeout, TimeoutExt},
|
||||
};
|
||||
|
||||
|
@ -6,7 +6,7 @@ use super::{process_filter::ProcessFilter, signal::constants::SIGCHLD, ExitCode,
|
||||
use crate::{
|
||||
prelude::*,
|
||||
process::{
|
||||
posix_thread::{thread_table, PosixThreadExt},
|
||||
posix_thread::{thread_table, AsPosixThread},
|
||||
process_table,
|
||||
signal::with_signal_blocked,
|
||||
},
|
||||
|
@ -8,7 +8,7 @@ use super::SyscallReturn;
|
||||
use crate::{
|
||||
prelude::*,
|
||||
process::{
|
||||
posix_thread::{thread_table, PosixThreadExt},
|
||||
posix_thread::{thread_table, AsPosixThread},
|
||||
process_table,
|
||||
},
|
||||
time::{
|
||||
|
@ -347,7 +347,7 @@ macro_rules! log_syscall_entry {
|
||||
let syscall_name_str = stringify!($syscall_name);
|
||||
let pid = $crate::current!().pid();
|
||||
let tid = {
|
||||
use $crate::process::posix_thread::PosixThreadExt;
|
||||
use $crate::process::posix_thread::AsPosixThread;
|
||||
$crate::current_thread!().as_posix_thread().unwrap().tid()
|
||||
};
|
||||
log::info!(
|
||||
|
@ -5,7 +5,7 @@ use core::sync::atomic::Ordering;
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
prelude::*,
|
||||
process::{posix_thread::PosixThreadExt, process_table, Pgid, Pid, Process, Uid},
|
||||
process::{posix_thread::AsPosixThread, process_table, Pgid, Pid, Process, Uid},
|
||||
sched::priority::{Nice, NiceRange},
|
||||
};
|
||||
|
||||
|
@ -7,7 +7,7 @@ use super::{
|
||||
use crate::{
|
||||
prelude::*,
|
||||
process::{
|
||||
posix_thread::{thread_table, PosixThreadExt},
|
||||
posix_thread::{thread_table, AsPosixThread},
|
||||
process_table,
|
||||
signal::{
|
||||
c_types::{sigevent_t, SigNotify},
|
||||
|
@ -5,7 +5,7 @@ use ostd::{
|
||||
task::{Task, TaskOptions},
|
||||
};
|
||||
|
||||
use super::{oops, status::ThreadStatus, Thread, ThreadExt};
|
||||
use super::{oops, status::ThreadStatus, AsThread, Thread};
|
||||
use crate::{prelude::*, sched::priority::Priority};
|
||||
|
||||
/// The inner data of a kernel thread.
|
||||
|
@ -162,13 +162,13 @@ impl Thread {
|
||||
}
|
||||
}
|
||||
|
||||
/// An extension trait for [`Thread`]-like types.
|
||||
pub trait ThreadExt {
|
||||
/// A trait to provide the `as_thread` method for tasks.
|
||||
pub trait AsThread {
|
||||
/// Returns the associated [`Thread`].
|
||||
fn as_thread(&self) -> Option<&Arc<Thread>>;
|
||||
}
|
||||
|
||||
impl ThreadExt for Task {
|
||||
impl AsThread for Task {
|
||||
fn as_thread(&self) -> Option<&Arc<Thread>> {
|
||||
self.data().downcast_ref::<Arc<Thread>>()
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ use crate::{
|
||||
cpu::LinuxAbi,
|
||||
get_current_userspace,
|
||||
prelude::*,
|
||||
process::{posix_thread::PosixThreadExt, signal::handle_pending_signal},
|
||||
process::{posix_thread::AsPosixThread, signal::handle_pending_signal},
|
||||
syscall::handle_syscall,
|
||||
thread::exception::handle_exception,
|
||||
vm::vmar::is_userspace_vaddr,
|
||||
|
@ -11,7 +11,7 @@ use super::worker_pool::WorkerPool;
|
||||
use crate::{
|
||||
prelude::*,
|
||||
sched::priority::{Priority, PriorityRange},
|
||||
thread::{kernel_thread::ThreadOptions, ThreadExt},
|
||||
thread::{kernel_thread::ThreadOptions, AsThread},
|
||||
};
|
||||
|
||||
/// A worker thread. A `Worker` will attempt to retrieve unfinished
|
||||
|
@ -17,7 +17,7 @@ use super::{simple_scheduler::SimpleScheduler, worker::Worker, WorkItem, WorkPri
|
||||
use crate::{
|
||||
prelude::*,
|
||||
sched::priority::{Priority, PriorityRange},
|
||||
thread::{kernel_thread::ThreadOptions, ThreadExt},
|
||||
thread::{kernel_thread::ThreadOptions, AsThread},
|
||||
};
|
||||
|
||||
/// A pool of workers.
|
||||
|
Reference in New Issue
Block a user