Attribute Macro lamellar_impl::local_am

source ·
#[local_am]
Expand description

§Examples

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

 #[AmLocalData(Debug,Clone)]
 struct HelloWorld {
     originial_pe: Arc<Mutex<usize>>, //This would not be allowed in a non-local AM as Arc<Mutex<<>> is not (de)serializable
 }

 #[lamellar::local_am]
 impl LamellarAM for HelloWorld {
     async fn exec(self) {
         println!(
             "Hello World  on PE {:?} of {:?} using thread {:?}, received from PE {:?}",
             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 = Arc::new(Mutex::new(world.my_pe()));
     world.barrier();

     let request = world.exec_am_local(HelloWorld {
         originial_pe: my_pe,
     });

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