[−][src]Struct wlambda::threads::Sender
The Sender sends RPC calls to the Receiver thread. Any values passed by WLambda code are serialized into msgpack internally and transmitted to the thread in String form. This means, your values must not be cyclic or contain non serializable data like external handles.
The Sender also provides a method for storing a sending function in the global variables for the EvalContext.
let mut ctx = wlambda::compiler::EvalContext::new_default(); let mut msg_handle = wlambda::threads::MsgHandle::new(); let sender = msg_handle.sender(); // You may register on multiple threads, but only one thread can use it at a time. sender.register_on_as(&mut ctx, "worker"); // start thread here...
Methods
impl Sender[src]
pub fn register_on_as(&self, ctx: &mut EvalContext, variable_name: &str)[src]
Registers a call and message sending function on the supplied EvalContext. You can call this function with the global variable name of the thread function you want to call and additional arguments to that function.
let mut ctx = wlambda::compiler::EvalContext::new_default(); let mut msg_handle = wlambda::threads::MsgHandle::new(); let sender = msg_handle.sender(); sender.register_on_as(&mut ctx, "worker"); ctx.eval("worker_call :displayln \"hello world from worker thread!\";").unwrap(); // _send will not wait for the call to be finished or even started. ctx.eval("worker_send :displayln \"hello world from worker thread!\";").unwrap();
pub fn call(&self, var_name: &str, args: VVal) -> VVal[src]
Calls the global variable in the receiver thread
with the given argument vector. You can pass none value
as args too.
pub fn send(&self, var_name: &str, args: VVal)[src]
With send you can asynchronously send messages in form of
method calls to the receiver. The Receiver will process all
received messages per step(). Multiple senders can send
messages, while multiple Receivers can process them.
Trait Implementations
Auto Trait Implementations
impl Send for Sender
impl Sync for Sender
impl Unpin for Sender
impl !UnwindSafe for Sender
impl !RefUnwindSafe for Sender
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> From<T> for T[src]
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,