mardi 4 décembre 2018

Multiple instance of a class member method

I have a scenario as explained below.

A set of data arrives at a port. Now the code that receives the data is multi threaded and has a logic that any of many callback registered handlers will read it from a pool. So we can have many active callback handlers active at any given time.

Now each handler has same processing logic but later within the flow it invokes a class method thru an object created as unique_ptr type. Hence as such this method can be invoked by multiple callbacks at any given time.

I understand that in memory class method instances are only one but data members have multiple instances to as many objects are created.

Is it that the object method if invoked multiple time via an object created by a unique_ptr type - each method will have instance of its own. I mean to say that say if the method is called N times - so there will be N instances of the method in memory. The same is cause local variables declared with the method will then have N instances and concurrency can be maintained(the method returns value of a local variable)? Is my understanding correct? What are the consideration we should take in coding such a class method?

Aucun commentaire:

Enregistrer un commentaire