lundi 13 avril 2015

Message receive for c++ actor system

I am trying to implement message handling for actors in c++. The following code in scala is something I am trying to implement in c++



def receive = {
case Message1 =>{/* logic code */}
case Message2 =>{/* logic code */}
}


Thus the idea is to create a set of handler functions for the various message type and create a dispatch method to route the message to its appropiate message handler. All messages will extends the base message type.


What would be the best approach to solve this problem:




  1. Maintain a Map(Message_type, function_pointer), the dispatch method will check the map and call the appropiate method. This mapping however needs to be done mannually in the Actor class.




  2. I read this library, the lbrary is handling message exactly as I want to but I cant understand how they do pattern matching on the lambda fucntions created on line 56.




I would appreciate any suggestion or reading links that could get me closer to the solution of this problem.


Aucun commentaire:

Enregistrer un commentaire