Concurrency - Lambda based message passing
#4
But this simple system also works for returned results: Make the other process send a message back via a nested lambda. Deadlock nonexistence guaranteed.

cRoot::foo would like to access cWorld::isNameDupe:

void cRoot::foo(cPlayer & a_Player)
{
    a_Player.GetWorld()->message([this, a_Player](cWorld & a_World){
      if (a_World.IsNameDupe(a_Player.GetName()))
      {
          this.message([a_Player](cRoot & a_Root){
            a_Player->myn(); // or whatever.
            a_Player->qwerty(5, 20); // or whatever.
          });
      }
      else
      {
         this.message([a_Player](cRoot & a_Root){
           a_Player.xyz()  // or whatever
           a_Player.abc(a_Root.ikj());  // or whatever.
           a_Root.etc(); // or whatever.
         });
      }
   });
}
Reply
Thanks given by:


Messages In This Thread
RE: Concurrency - Lambda based message passing - by LogicParrot - 02-17-2016, 10:58 PM



Users browsing this thread: 2 Guest(s)