pub struct WorkerContext { /* private fields */ }Implementations§
Source§impl WorkerContext
impl WorkerContext
pub fn new<E: ModrpcExecutor>( rt: RuntimeHandle, spawner: LocalSpawner, shutdown_signal: SignalTree, worker_id: WorkerId, worker_count: u16, pp: Rc<PacketProcessor>, local_packet_tx: Sender<Packet>, locals: Rc<RefCell<LocalContextMap>>, globals: Arc<Mutex<ContextMap>>, ) -> Self
pub fn rt(&self) -> &RuntimeHandle
pub fn spawner(&self) -> WorkerSpawner
pub fn worker_id(&self) -> WorkerId
pub fn worker_count(&self) -> u16
pub fn local_packet_tx(&self) -> &Sender<Packet>
pub async fn sleep(&self, duration: Duration)
pub fn spawn(&self, future: impl Future<Output = ()> + 'static)
pub fn new_sleeper(&self) -> Pin<Box<dyn Sleeper>>
pub fn spawn_interval_loop<'a>( &self, interval_duration: Duration, f: impl FnMut() + 'static, )
pub fn spawn_traced( &self, name: &str, flush_interval: Duration, f: impl AsyncFnOnce(&TraceSource) + 'static, )
pub fn with_local<T, U>(
&self,
key: T::Key,
params: &T::Params,
f: impl FnOnce(&mut T) -> U,
) -> Uwhere
T: ContextClass + 'static,
pub fn with_local_fn<K, T, U>( &self, key: K, constructor: impl FnOnce() -> T, f: impl FnOnce(&mut T) -> U, ) -> U
pub fn with_global<T, U>( &self, key: T::Key, params: &T::Params, f: impl FnOnce(&mut T) -> U, ) -> U
pub fn add_handler( &self, topic_name: &str, source_filter: PacketProcessorSource, plane_id: u32, topic: u32, handler: impl FnMut(EndpointAddr, &Packet) + 'static, )
pub fn add_local_queue( &self, topic_name: &str, source_filter: PacketProcessorSource, plane_id: u32, topic: u32, queue: Sender<Packet>, )
pub fn route_to_local_queue( &self, topic_name: &str, source_filter: PacketProcessorSource, plane_id: u32, topic: u32, handler: impl FnMut(EndpointAddr, &Packet) -> Option<Sender<Packet>> + 'static, )
pub fn add_redirect_to_worker( &self, topic_name: &str, source_filter: PacketProcessorSource, plane_id: u32, topic: u32, to_worker: WorkerId, )
pub fn route_to_worker( &self, topic_name: &str, source_filter: PacketProcessorSource, plane_id: u32, topic: u32, handler: impl FnMut(EndpointAddr, &Packet) -> Option<WorkerId> + 'static, )
Sourcepub fn get_packet_processor(&self) -> impl AsyncFn(&Packet) + 'static
pub fn get_packet_processor(&self) -> impl AsyncFn(&Packet) + 'static
Get an async closure that can inject packets on this worker. Intended to be used by custom Transport implementations.
Trait Implementations§
Source§impl Clone for WorkerContext
impl Clone for WorkerContext
Source§fn clone(&self) -> WorkerContext
fn clone(&self) -> WorkerContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for WorkerContext
impl !RefUnwindSafe for WorkerContext
impl !Send for WorkerContext
impl !Sync for WorkerContext
impl Unpin for WorkerContext
impl !UnwindSafe for WorkerContext
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
Mutably borrows from an owned value. Read more