pub struct Worker { /* private fields */ }
Expand description
Worker context, containing ‘global’ information for the current thread.
Implementations§
source§impl Worker
impl Worker
pub fn new_for_this_thread(worker_id: WorkerThreadID)
sourcepub fn with_active_host<F, R>(f: F) -> Option<R>
pub fn with_active_host<F, R>(f: F) -> Option<R>
Run f
with a reference to the current Host, or return None if there is no current Host.
sourcepub fn with_active_process_rc<F, R>(f: F) -> Option<R>
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
.
sourcepub fn with_active_process<F, R>(f: F) -> Option<R>
pub fn with_active_process<F, R>(f: F) -> Option<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
.
sourcepub fn with_active_thread<F, R>(f: F) -> Option<R>
pub fn with_active_thread<F, R>(f: F) -> Option<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
.
sourcepub fn with_dns<F, R>(f: F) -> R
pub fn with_dns<F, R>(f: F) -> R
Run f
with a reference to the global DNS.
Panics if the Worker or its DNS hasn’t yet been initialized.
sourcepub fn set_active_host(host: Box<Host>)
pub fn set_active_host(host: Box<Host>)
Set the currently-active Host.
sourcepub fn take_active_host() -> Box<Host>
pub fn take_active_host() -> Box<Host>
Clear the currently-active Host.
sourcepub fn set_active_process(process: &RootedRc<RootedRefCell<Process>>)
pub fn set_active_process(process: &RootedRc<RootedRefCell<Process>>)
Set the currently-active Process.
sourcepub fn clear_active_process()
pub fn clear_active_process()
Clear the currently-active Process.
sourcepub fn set_active_thread(thread: &RootedRc<RootedRefCell<Thread>>)
pub fn set_active_thread(thread: &RootedRc<RootedRefCell<Thread>>)
Set the currently-active Thread.
sourcepub fn clear_active_thread()
pub fn clear_active_thread()
Clear the currently-active Thread.
sourcepub fn worker_id() -> Option<WorkerThreadID>
pub fn worker_id() -> Option<WorkerThreadID>
ID of this thread’s Worker, if any.
pub fn active_process_native_pid() -> Option<Pid>
pub fn active_process_id() -> Option<ProcessId>
pub fn active_thread_id() -> Option<ThreadId>
pub fn active_thread_native_tid() -> Option<Pid>
pub fn set_round_end_time(t: EmulatedTime)
sourcepub fn max_event_runahead_time(host: &Host) -> EmulatedTime
pub fn max_event_runahead_time(host: &Host) -> EmulatedTime
Maximum time that the current event may run ahead to.
pub fn set_current_time(t: EmulatedTime)
pub fn clear_current_time()
pub fn current_time() -> Option<EmulatedTime>
pub fn update_lowest_used_latency(t: SimulationTime)
pub fn reset_next_event_time()
pub fn get_next_event_time() -> Option<EmulatedTime>
pub fn update_next_event_time(t: EmulatedTime)
sourcepub unsafe fn send_packet(src_host: &Host, packet: *mut Packet)
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.
pub fn increment_object_alloc_counter(s: &str)
pub fn increment_object_dealloc_counter(s: &str)
pub fn add_syscall_counts(syscall_counts: &Counter)
pub fn add_to_global_sim_stats()
pub fn is_routable(src: IpAddr, dst: IpAddr) -> bool
pub fn increment_plugin_error_count()
sourcepub fn is_bootstrapping() -> bool
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.
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> 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
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