Struct cargo::core::compiler::job_queue::DrainState

source ·
struct DrainState<'gctx> {
Show 18 fields total_units: usize, queue: DependencyQueue<Unit, Artifact, Job>, messages: Arc<Queue<Message>>, diag_dedupe: DiagDedupe<'gctx>, warning_count: HashMap<JobId, WarningCount>, active: HashMap<JobId, Unit>, compiled: HashSet<PackageId>, documented: HashSet<PackageId>, scraped: HashSet<PackageId>, counts: HashMap<PackageId, usize>, progress: Progress<'gctx>, next_id: u32, timings: Timings<'gctx>, tokens: Vec<Acquired>, pending_queue: Vec<(Unit, Job, usize)>, print: DiagnosticPrinter<'gctx>, finished: usize, per_package_future_incompat_reports: Vec<FutureIncompatReportPackage>,
}
Expand description

This structure is backed by the DependencyQueue type and manages the actual compilation step of each package. Packages enqueue units of work and then later on the entire graph is processed and compiled.

It is created from JobQueue when we have fully assembled the crate graph (i.e., all package dependencies are known).

Fields§

§total_units: usize§queue: DependencyQueue<Unit, Artifact, Job>§messages: Arc<Queue<Message>>§diag_dedupe: DiagDedupe<'gctx>

Diagnostic deduplication support.

§warning_count: HashMap<JobId, WarningCount>

Count of warnings, used to print a summary after the job succeeds

§active: HashMap<JobId, Unit>§compiled: HashSet<PackageId>§documented: HashSet<PackageId>§scraped: HashSet<PackageId>§counts: HashMap<PackageId, usize>§progress: Progress<'gctx>§next_id: u32§timings: Timings<'gctx>§tokens: Vec<Acquired>

Tokens that are currently owned by this Cargo, and may be “associated” with a rustc process. They may also be unused, though if so will be dropped on the next loop iteration.

Note that the length of this may be zero, but we will still spawn work, as we share the implicit token given to this Cargo process with a single rustc process.

§pending_queue: Vec<(Unit, Job, usize)>

The list of jobs that we have not yet started executing, but have retrieved from the queue. We eagerly pull jobs off the main queue to allow us to request jobserver tokens pretty early.

§print: DiagnosticPrinter<'gctx>§finished: usize

How many jobs we’ve finished

§per_package_future_incompat_reports: Vec<FutureIncompatReportPackage>

Implementations§

source§

impl<'gctx> DrainState<'gctx>

source

fn spawn_work_if_possible<'s>( &mut self, build_runner: &mut BuildRunner<'_, '_>, jobserver_helper: &HelperThread, scope: &'s Scope<'s, '_>, ) -> CargoResult<()>

source

fn has_extra_tokens(&self) -> bool

source

fn handle_event( &mut self, build_runner: &mut BuildRunner<'_, '_>, plan: &mut BuildPlan, event: Message, ) -> Result<(), ErrorToHandle>

source

fn wait_for_events(&mut self) -> Vec<Message>

source

fn drain_the_queue<'s>( self, build_runner: &mut BuildRunner<'_, '_>, plan: &mut BuildPlan, scope: &'s Scope<'s, '_>, jobserver_helper: &HelperThread, ) -> Option<Error>

This is the “main” loop, where Cargo does all work to run the compiler.

This returns an Option to prevent the use of ? on Result types because it is important for the loop to carefully handle errors.

source

fn handle_error( &self, shell: &mut Shell, err_state: &mut ErrorsDuringDrain, new_err: impl Into<ErrorToHandle>, )

source

fn tick_progress(&mut self)

source

fn name_for_progress(&self, unit: &Unit) -> String

source

fn run<'s>( &mut self, unit: &Unit, job: Job, build_runner: &BuildRunner<'_, '_>, scope: &'s Scope<'s, '_>, )

Executes a job.

Fresh jobs block until finished (which should be very fast!), Dirty jobs will spawn a thread in the background and return immediately.

source

fn emit_warnings( &mut self, msg: Option<&str>, unit: &Unit, build_runner: &mut BuildRunner<'_, '_>, ) -> CargoResult<()>

source

fn bump_warning_count(&mut self, id: JobId, emitted: bool, fixable: bool)

source

fn report_warning_count( &mut self, gctx: &GlobalContext, id: JobId, rustc_workspace_wrapper: &Option<PathBuf>, )

Displays a final report of the warnings emitted by a particular job.

source

fn finish( &mut self, id: JobId, unit: &Unit, artifact: Artifact, build_runner: &mut BuildRunner<'_, '_>, ) -> CargoResult<()>

source

fn note_working_on( &mut self, gctx: &GlobalContext, ws_root: &Path, unit: &Unit, fresh: &Freshness, ) -> CargoResult<()>

source

fn back_compat_notice( &self, build_runner: &BuildRunner<'_, '_>, unit: &Unit, ) -> CargoResult<()>

Auto Trait Implementations§

§

impl<'gctx> !Freeze for DrainState<'gctx>

§

impl<'gctx> !RefUnwindSafe for DrainState<'gctx>

§

impl<'gctx> !Send for DrainState<'gctx>

§

impl<'gctx> !Sync for DrainState<'gctx>

§

impl<'gctx> Unpin for DrainState<'gctx>

§

impl<'gctx> !UnwindSafe for DrainState<'gctx>

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

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> Same for T

source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 1176 bytes