Attribute Macro lamellar_impl::am

source ·
#[am]
Expand description

§Examples

 use lamellar::active_messaging::prelude::*;
 use lamellar::darc::prelude::*;

 #[AmData(Debug,Clone)]
 struct HelloWorld {
    originial_pe: usize,
    #[AmData(static)]
    msg: Darc<String>,
 }

 #[lamellar::am]
 impl LamellarAM for HelloWorld {
     async fn exec(self) {
         println!(
             "{:?}}  on PE {:?} of {:?} using thread {:?}, received from PE {:?}",
             self.msg,
             lamellar::current_pe,
             lamellar::num_pes,
             std::thread::current().id(),
             self.originial_pe.lock(),
         );
     }
 }
 fn main() {
     let world = lamellar::LamellarWorldBuilder::new().build();
     let my_pe = world.my_pe();
     world.barrier();
     let msg = Darc::<String>::new(&world, "Hello World".to_string());
     //Send a Hello World Active Message to all pes
     let request = world.exec_am_all(HelloWorld {
         originial_pe: my_pe,
         msg: msg,
     });

     //wait for the request to complete
     world.block_on(request);
 } //when world drops there is an implicit world.barrier() that occurs