Struct SharedTask

Source
pub struct SharedTask { /* private fields */ }
Available on crate features shared_mem or pocl_extensions only.

Implementations§

Source§

impl SharedTask

Represents a shared task handle, that can be use to await the completion of a task on a different process from the one which created it

Source

pub async fn wait(&self)

Await the completetion of the shared task. This is an asynchronous operation, meaning that no work is actually performed until the returned future is actualy awaited. While awaiting a task execution, the user application will not make forward progress until the underylying device has executed the task and performed any necessary data transfers. Upon return from the await call, any output data is gauranteed to be written to its approriate buffer.

Task execution order can be enforced be sequentially awaiting tasks, or may be executed simultaneous using data structures such as Join_all https://docs.rs/futures/latest/futures/future/fn.join_all.html

§Examples
     let mcl = mcl_rs::MclEnvBuilder::new().num_workers(10).initialize();
     mcl.load_prog("my_path", mcl_rs::PrgType::Src);
     let pid = 0; //user is required to set this approriately
     let task_ids = [0,1,2,3]; //user is required to set this approriately

     let t1 = mcl.attach_shared_task(pid,task_ids[0]);
     let t2 = mcl.attach_shared_task(pid,task_ids[1]);
     let t3 = mcl.attach_shared_task(pid,task_ids[2]);
     let t4 = mcl.attach_shared_task(pid,task_ids[3]);
     
     let tasks = async move {
         t1.await;
         t2.await;
         futures::future::join_all([t3,t4]).await;
     }
     futures::executor::block_on(tasks);

Auto Trait Implementations§

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