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.
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>
impl<VM: VMBinding> GCWorker<VM>
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
const LOCALLY_CACHED_WORK_PACKETS: usize = 16usize
sourcepub fn add_work_prioritized(
&mut self,
bucket: WorkBucketStage,
work: impl GCWork<VM>
)
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.
sourcepub fn add_work(&mut self, bucket: WorkBucketStage, work: impl GCWork<VM>)
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.
sourcepub fn scheduler(&self) -> &GCWorkScheduler<VM>
pub fn scheduler(&self) -> &GCWorkScheduler<VM>
Get the scheduler. There is only one scheduler per MMTk instance.
sourcepub fn get_copy_context_mut(&mut self) -> &mut GCWorkerCopyContext<VM>
pub fn get_copy_context_mut(&mut self) -> &mut GCWorkerCopyContext<VM>
Get a mutable reference of the copy context for this worker.
sourcefn poll(&mut self) -> Result<Box<dyn GCWork<VM>>, WorkerShouldExit>
fn poll(&mut self) -> Result<Box<dyn GCWork<VM>>, WorkerShouldExit>
Poll a ready-to-execute work packet in the following order:
- Any packet that should be processed only by this worker.
- Poll from the local work queue.
- Poll from activated global work-buckets
- Steal from other workers
sourcepub fn run(self: Box<Self>, tls: VMWorkerThread, mmtk: &'static MMTK<VM>)
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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