[][src]Struct winproc::Thread

pub struct Thread { /* fields omitted */ }

A handle to a running thread.

Methods

impl Thread[src]

pub fn from_id(id: u32) -> WinResult<Thread>[src]

Creates a thread handle from a thread ID.

pub fn current() -> Thread[src]

Returns a handle to the current thread.

pub fn handle(&self) -> &Handle[src]

pub fn id(&self) -> u32[src]

Return's the thread's ID.

pub fn cycle_time(&self) -> WinResult<u64>[src]

Returns the thread's cycle time.

pub fn priority(&self) -> WinResult<PriorityLevel>[src]

Returns the priority level of the thread.

The handle must have the THREAD_QUERY_INFORMATION or THREAD_QUERY_LIMITED_INFORMATION access right.

pub fn set_priority(&mut self, priority: PriorityLevel) -> WinResult[src]

Sets the priority level of the thread.

The handle must have the THREAD_SET_INFORMATION or THREAD_SET_LIMITED_INFORMATION access right.

pub fn start_background_mode(&mut self) -> WinResult[src]

Begins background processing mode.

This can be initiated only if the handle refers to the current thread.

The system lowers the resource scheduling priorities of the thread so that it can perform background work without significantly affecting activity in the foreground.

The function fails if the thread is already in background processing mode.

The handle must have the THREAD_SET_INFORMATION or THREAD_SET_LIMITED_INFORMATION access right.

pub fn end_background_mode(&mut self) -> WinResult[src]

Ends background processing mode.

This can be initiated only if the handle refers to the current thread.

The system restores the resource scheduling priorities of the thread as they were before the thread entered background processing mode.

The function fails if the thread is not in background processing mode.

The handle must have the THREAD_SET_INFORMATION or THREAD_SET_LIMITED_INFORMATION access right.

pub fn suspend(&mut self) -> WinResult<u32>[src]

Suspends the thread.

If the function succeeds, the return value is the thread's previous suspend count.

The handle must have the THREAD_SUSPEND_RESUME access right.

pub fn resume(&mut self) -> WinResult<u32>[src]

Resumes the thread.

If the function succeeds, the return value is the thread's previous suspend count.

The handle must have the THREAD_SUSPEND_RESUME access right.

pub fn terminate(&mut self, exit_code: u32) -> WinResult[src]

Terminates the thread.

The handle must have the THREAD_TERMINATE access right.

pub fn ideal_processor(&self) -> WinResult<u32>[src]

Returns the thread's ideal processor.

pub fn set_ideal_processor(&mut self, processor: u32) -> WinResult<u32>[src]

Sets the thread's ideal processor. On success, returns the previous ideal processor.

pub fn affinity_mask(&self) -> WinResult<usize>[src]

Returns the thread's current affinity mask.

pub fn set_affinity_mask(&mut self, mask: usize) -> WinResult<usize>[src]

Sets the affinity mask of the thread. On success, returns the previous affinity mask.

A thread affinity mask is a bit vector in which each bit represents a logical processor that a thread is allowed to run on. A thread affinity mask must be a subset of the process affinity mask for the containing process of a thread. A thread can only run on the processors its process can run on. Therefore, the thread affinity mask cannot specify a 1 bit for a processor when the process affinity mask specifies a 0 bit for that processor.

Setting an affinity mask for a process or thread can result in threads receiving less processor time, as the system is restricted from running the threads on certain processors. In most cases, it is better to let the system select an available processor.

If the new thread affinity mask does not specify the processor that is currently running the thread, the thread is rescheduled on one of the allowable processors.

pub fn set_affinity(&mut self, processor: u8) -> WinResult<usize>[src]

Sets the affinity of the thread to the single specified processor.

If the processor index equals or exceeds the width of usize, the mask is not changed. On success, or if unchanged, returns the previous affinity mask.

Trait Implementations

impl Deref for Thread[src]

type Target = HANDLE

The resulting type after dereferencing.

impl Debug for Thread[src]

impl AsRawHandle for Thread[src]

impl IntoRawHandle for Thread[src]

impl FromRawHandle for Thread[src]

Auto Trait Implementations

impl !Sync for Thread

impl !Send for Thread

impl Unpin for Thread

impl RefUnwindSafe for Thread

impl UnwindSafe for Thread

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]