Struct mmtk::scheduler::GCWorker

source ·
pub struct GCWorker<VM: VMBinding> {
    pub tls: VMWorkerThread,
    pub ordinal: usize,
    scheduler: Arc<GCWorkScheduler<VM>>,
    copy: GCWorkerCopyContext<VM>,
    pub mmtk: &'static MMTK<VM>,
    pub shared: Arc<GCWorkerShared<VM>>,
    pub local_work_buffer: Worker<Box<dyn GCWork<VM>>>,
}
Expand description

A GC worker. This part is privately owned by a worker thread.

Fields§

§tls: VMWorkerThread

The VM-specific thread-local state of the GC thread.

§ordinal: usize

The ordinal of the worker, numbered from 0 to the number of workers minus one.

§scheduler: Arc<GCWorkScheduler<VM>>

The reference to the scheduler.

§copy: GCWorkerCopyContext<VM>

The copy context, used to implement copying GC.

§mmtk: &'static MMTK<VM>

The reference to the MMTk instance.

§shared: Arc<GCWorkerShared<VM>>

Reference to the shared part of the GC worker. It is used for synchronization.

§local_work_buffer: Worker<Box<dyn GCWork<VM>>>

Local work packet queue.

Implementations§

source§

impl<VM: VMBinding> GCWorker<VM>

source

pub(crate) fn new( mmtk: &'static MMTK<VM>, ordinal: usize, scheduler: Arc<GCWorkScheduler<VM>>, shared: Arc<GCWorkerShared<VM>>, local_work_buffer: Worker<Box<dyn GCWork<VM>>> ) -> Self

source

const LOCALLY_CACHED_WORK_PACKETS: usize = 16usize

source

pub fn add_work_prioritized( &mut self, bucket: WorkBucketStage, work: impl GCWork<VM> )

Add a work packet to the work queue and mark it with a higher priority. If the bucket is activated, the packet will be pushed to the local queue, otherwise it will be pushed to the global bucket with a higher priority.

source

pub fn add_work(&mut self, bucket: WorkBucketStage, work: impl GCWork<VM>)

Add a work packet to the work queue. If the bucket is activated, the packet will be pushed to the local queue, otherwise it will be pushed to the global bucket.

source

pub fn scheduler(&self) -> &GCWorkScheduler<VM>

Get the scheduler. There is only one scheduler per MMTk instance.

source

pub fn get_copy_context_mut(&mut self) -> &mut GCWorkerCopyContext<VM>

Get a mutable reference of the copy context for this worker.

source

fn poll(&mut self) -> Result<Box<dyn GCWork<VM>>, WorkerShouldExit>

Poll a ready-to-execute work packet in the following order:

  1. Any packet that should be processed only by this worker.
  2. Poll from the local work queue.
  3. Poll from activated global work-buckets
  4. Steal from other workers
source

pub fn run(self: Box<Self>, tls: VMWorkerThread, mmtk: &'static MMTK<VM>)

Entry point of the worker thread.

This function will resolve thread affinity, if it has been specified by the user.

Each worker will keep polling and executing work packets in a loop. It runs until the worker is requested to exit. Currently a worker may exit after crate::mmtk::MMTK::prepare_to_fork is called.

Arguments:

  • tls: The VM-specific thread-local storage for this GC worker thread.
  • mmtk: A reference to an MMTk instance.

Auto Trait Implementations§

§

impl<VM> !RefUnwindSafe for GCWorker<VM>

§

impl<VM> Send for GCWorker<VM>

§

impl<VM> !Sync for GCWorker<VM>

§

impl<VM> Unpin for GCWorker<VM>

§

impl<VM> !UnwindSafe for GCWorker<VM>

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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>,

§

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.