dimanche 4 novembre 2018

Initial state for the stateful_actor in CAF

I'm using CAF to model a problem for my final year thesis and I've come across a scenario which I believe is not documented. In the example curl/curl_fuse.cpp a stateful curl_worker actor is defined and spawned as follows:

behavior curl_worker(stateful_actor<curl_state>* self, const actor& parent) {
   return {
      ...
   };
}

...

behavior curl_master(stateful_actor<master_state>* self) {
   self->spawn<detached+linked>(curl_worker, self));
}

I recognize that the purpose of this approach is to isolate actors' state and prevent cyclic references, but is it possible to construct the initial curl_state and pass it to the actor during spawn?

I know this can be done with class-based actors, however I'd want to avoid those due to aforementioned reference problem.

Aucun commentaire:

Enregistrer un commentaire