Skip to main content

SearchScratch

Struct SearchScratch 

Source
pub struct SearchScratch<S: Storage> { /* private fields */ }
Expand description

Working memory of Plan::fits and Plan::earliest_start, for callers that keep it outside the stack.

With Fixed<N> storage it holds two change-point lists of 2 N points and a set and a requirement list of N entries, 216 N + 128 bytes on 64-bit targets: 58 KiB for N = 256. fits and earliest_start put it on the stack; Plan::fits_with and Plan::earliest_start_with borrow one instead, for example from a static or a task’s own memory. Measured on x86-64 (release, frame sizes from -Z emit-stack-sizes, confirmed by running in threads of shrinking stack): a search over a FixedPlan<2, 1, 256> needs about 60 KiB of stack with the internal scratch and fits in a 16 KiB thread stack with a borrowed one; its largest frame is the 2.4 KiB of the change-point sort. Explaining a violation (first_violation) keeps its own per-activity working list of 32 N bytes on the stack, about 16 KiB for N = 256.

§Examples

use resource_timeline::storage::{Fixed, FixedPlan};
use resource_timeline::{ActivityId, Demand, Impact, Plan, SearchScratch, Timeline, Window};

let mut plan = Plan::<FixedPlan<1, 0, 64>>::new_in();
let transmitter = plan.add_timeline(Timeline::claimable_in(0, 1, 64)?)?;
let downlink = [Demand::Level {
    timeline: transmitter,
    impact: Impact::Claim { start: 0, end: 8, amount: 1 },
}];
plan.place(ActivityId(1), 5, &downlink)?;

let mut scratch = SearchScratch::<Fixed<64>>::new();
let window = Window::new(0, 100)?;
assert_eq!(plan.earliest_start_with(&downlink, window, 1_000, &mut scratch)?, Some(13));

Implementations§

Source§

impl<S: Storage> SearchScratch<S>

Source

pub const fn new() -> Self

Empty working memory.

Trait Implementations§

Source§

impl<S: Clone + Storage> Clone for SearchScratch<S>
where S::DoubleList<Point>: Clone, S::List<SetPoint>: Clone, S::List<Requirement>: Clone,

Source§

fn clone(&self) -> Self

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<S: Debug + Storage> Debug for SearchScratch<S>
where S::DoubleList<Point>: Debug, S::List<SetPoint>: Debug, S::List<Requirement>: Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<S: Storage> Default for SearchScratch<S>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S> Forget for SearchScratch<S>

§

impl<S> Freeze for SearchScratch<S>
where <S as Storage>::DoubleList<Point>: Freeze, <S as Storage>::List<SetPoint>: Freeze, <S as Storage>::List<Requirement>: Freeze,

§

impl<S> Move for SearchScratch<S>

§

impl<S> RefUnwindSafe for SearchScratch<S>
where <S as Storage>::DoubleList<Point>: RefUnwindSafe, <S as Storage>::List<SetPoint>: RefUnwindSafe, <S as Storage>::List<Requirement>: RefUnwindSafe,

§

impl<S> Send for SearchScratch<S>
where <S as Storage>::DoubleList<Point>: Send, <S as Storage>::List<SetPoint>: Send, <S as Storage>::List<Requirement>: Send,

§

impl<S> Sync for SearchScratch<S>
where <S as Storage>::DoubleList<Point>: Sync, <S as Storage>::List<SetPoint>: Sync, <S as Storage>::List<Requirement>: Sync,

§

impl<S> Unpin for SearchScratch<S>
where <S as Storage>::DoubleList<Point>: Unpin, <S as Storage>::List<SetPoint>: Unpin, <S as Storage>::List<Requirement>: Unpin,

§

impl<S> UnsafeUnpin for SearchScratch<S>
where <S as Storage>::DoubleList<Point>: UnsafeUnpin, <S as Storage>::List<SetPoint>: UnsafeUnpin, <S as Storage>::List<Requirement>: UnsafeUnpin,

§

impl<S> UnwindSafe for SearchScratch<S>
where <S as Storage>::DoubleList<Point>: UnwindSafe, <S as Storage>::List<SetPoint>: UnwindSafe, <S as Storage>::List<Requirement>: UnwindSafe,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.