Struct shadow_rs::core::worker::Worker

source ·
pub struct Worker { /* private fields */ }
Expand description

Worker context, containing ‘global’ information for the current thread.

Implementations§

source§

impl Worker

source

pub fn new_for_this_thread(worker_id: WorkerThreadID)

source

pub fn with_active_host<F, R>(f: F) -> Option<R>
where F: FnOnce(&Host) -> R,

Run f with a reference to the current Host, or return None if there is no current Host.

source

pub fn with_active_process_rc<F, R>(f: F) -> Option<R>

Run f with a reference to the current RootedRc<RootedRefCell<Process>>, or return None if there isn’t one.

Prefer to pass Process explicitly where feasible. e.g. see ProcessContext.

source

pub fn with_active_process<F, R>(f: F) -> Option<R>
where F: FnOnce(&Process) -> R,

Run f with a reference to the current Process, or return None if there isn’t one.

Prefer to pass Process explicitly where feasible. e.g. see ProcessContext.

source

pub fn with_active_thread<F, R>(f: F) -> Option<R>
where F: FnOnce(&Thread) -> R,

Run f with a reference to the current Thread, or return None if there isn’t one.

Prefer to pass Thread explicitly where feasible. e.g. see ThreadContext.

source

pub fn with_dns<F, R>(f: F) -> R
where F: FnOnce(&DNS) -> R,

Run f with a reference to the global DNS.

Panics if the Worker or its DNS hasn’t yet been initialized.

source

pub fn set_active_host(host: Box<Host>)

Set the currently-active Host.

source

pub fn take_active_host() -> Box<Host>

Clear the currently-active Host.

source

pub fn set_active_process(process: &RootedRc<RootedRefCell<Process>>)

Set the currently-active Process.

source

pub fn clear_active_process()

Clear the currently-active Process.

source

pub fn set_active_thread(thread: &RootedRc<RootedRefCell<Thread>>)

Set the currently-active Thread.

source

pub fn clear_active_thread()

Clear the currently-active Thread.

source

pub fn is_alive() -> bool

Whether currently running on a live Worker.

source

pub fn worker_id() -> Option<WorkerThreadID>

ID of this thread’s Worker, if any.

source

pub fn active_process_native_pid() -> Option<Pid>

source

pub fn active_process_id() -> Option<ProcessId>

source

pub fn active_thread_id() -> Option<ThreadId>

source

pub fn active_thread_native_tid() -> Option<Pid>

source

pub fn set_round_end_time(t: EmulatedTime)

source

pub fn max_event_runahead_time(host: &Host) -> EmulatedTime

Maximum time that the current event may run ahead to.

source

pub fn set_current_time(t: EmulatedTime)

source

pub fn clear_current_time()

source

pub fn current_time() -> Option<EmulatedTime>

source

pub fn update_lowest_used_latency(t: SimulationTime)

source

pub fn reset_next_event_time()

source

pub fn get_next_event_time() -> Option<EmulatedTime>

source

pub fn update_next_event_time(t: EmulatedTime)

source

pub unsafe fn send_packet(src_host: &Host, packet: *mut Packet)

The packet will be dropped if the packet’s destination IP is not part of the simulation (no host has been configured for the IP).

§Safety

packet must be valid and not accessed by another thread while this function is running.

source

pub fn increment_object_alloc_counter(s: &str)

source

pub fn increment_object_dealloc_counter(s: &str)

source

pub fn add_syscall_counts(syscall_counts: &Counter)

source

pub fn add_to_global_sim_stats()

source

pub fn is_routable(src: IpAddr, dst: IpAddr) -> bool

source

pub fn increment_plugin_error_count()

source

pub fn is_bootstrapping() -> bool

Shadow allows configuration of a “bootstrapping” interval, during which hosts’ network activity does not consume bandwidth. Returns true if we are still within this preliminary interval, or false otherwise.

source

pub fn resolve_name_to_ip(name: &CStr) -> Option<Ipv4Addr>

Auto Trait Implementations§

§

impl !Freeze for Worker

§

impl !RefUnwindSafe for Worker

§

impl Send for Worker

§

impl !Sync for Worker

§

impl Unpin for Worker

§

impl !UnwindSafe for Worker

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.

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

impl<T> NoTypeInference for T

source§

type This = T

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

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

Initializes a with the given initializer. Read more
source§

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

Dereferences the given pointer. Read more
source§

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

Mutably dereferences the given pointer. Read more
source§

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

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.
source§

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

source§

fn vzip(self) -> V