Skip to main content

TidReceiver

Struct TidReceiver 

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

Emplacement mémoire où le kernel écrit (CLONE_PARENT_SETTID / CLONE_CHILD_SETTID) ou efface (CLONE_CHILD_CLEARTID) le TID d’un enfant créé par clone3.

Encapsule l’adresse d’un mot 32 bits partagé (AtomicU32) — un tid_t côté kernel — plutôt qu’un pointeur nu (convention 1 de l’ADR-021 : pas de pointeur brut non typé exposé). Le pattern de join de thread :

  • CLONE_PARENT_SETTID + parent_tid = &mot → le kernel écrit le TID dans le mot, dans le contexte du parent, avant le retour de clone3 (sans course avec une terminaison précoce de l’enfant) ;
  • CLONE_CHILD_CLEARTID + child_tid = &mot → à la mort du thread, le kernel remet le mot à 0 et effectue un FUTEX_WAKE dessus. Le parent joint donc en bouclant sur futex_wait(&mot, tid) jusqu’à lire 0.

Le mot doit rester vivant (et l’AtomicU32 non déplacé) jusqu’à la fin du join ; cette garantie incombe à l’appelant de la fonction unsafe clone_thread. Construire un TidReceiver est en soi inoffensif (on ne fait qu’enregistrer une adresse).

Implementations§

Source§

impl TidReceiver

Source

pub fn new(word: &AtomicU32) -> Self

Construit un récepteur à partir d’un mot atomique partagé vivant.

On ne capture que l’adresse du mot ; sa validité au moment de l’appel clone3/clone_thread (et jusqu’au join) relève du contrat unsafe de ces fonctions.

Source

pub fn as_ptr(self) -> *mut u32

Retourne le pointeur brut du mot, pour le marshalling vers la structure clone_args du kernel (réservé aux wrappers de la couche 0).

Trait Implementations§

Source§

impl Clone for TidReceiver

Source§

fn clone(&self) -> TidReceiver

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for TidReceiver

Source§

impl Debug for TidReceiver

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.