Skip to main content

Thread

Struct Thread 

Source
pub struct Thread { /* private fields */ }
Expand description

Wrapper around an IL2CPP VM thread attachment.

Use this type whenever your code touches IL2CPP from a thread that was not created by the crate’s initialization flow. The common pattern is scoped attachment via Thread::attach with auto_detach = true.

Implementations§

Source§

impl Thread

Source

pub unsafe fn from_ptr(thread_ptr: *mut c_void, auto_detach: bool) -> Self

Creates a Thread wrapper from a raw pointer

§Arguments
  • thread_ptr - The raw IL2CPP thread pointer
  • auto_detach - Whether to detach the thread when this struct is dropped
§Safety
  • thread_ptr must be a valid IL2CPP thread pointer.
Source

pub fn as_ptr(&self) -> *mut c_void

Returns the raw pointer to the thread

Source

pub fn detach(self)

Manually detaches the thread from the IL2CPP domain

This will detach the thread immediately and prevent auto-detachment on drop.

Source

pub fn is_vm_thread(&self) -> bool

Checks if the thread is a VM thread

Source

pub fn current() -> Option<Self>

Gets the current attached thread

§Returns
  • Option<Self> - The current thread wrapper if attached, or None
Source

pub fn attach(auto_detach: bool) -> Option<Self>

Attaches the current OS thread to the IL2CPP domain.

If the thread is already attached, the existing thread handle is reused. When auto_detach is true, dropping the returned value detaches the thread automatically.

Returns None if the IL2CPP domain could not be resolved or the runtime rejected the attachment request.

Source

pub fn is_attached() -> bool

Checks if the current thread is attached to the IL2CPP domain

Source

pub fn all() -> Vec<Thread>

Gets all attached threads

§Returns
  • Vec<Thread> - A list of all threads currently attached to the IL2CPP domain

Trait Implementations§

Source§

impl Drop for Thread

Source§

fn drop(&mut self)

Detaches the thread from the IL2CPP domain if auto-detach is enabled

Source§

impl Send for Thread

Source§

impl Sync for Thread

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.