CAF and Object Oriented Programming

20 views
Skip to first unread message

Tanzeela Younas

unread,
Nov 29, 2021, 11:46:43 PM11/29/21
to actor-framework
How can we create or access the actor declared in class.
I have tried to do that . i was able to declare the actor (behavior) as an attribute of class but was not able to access it after making the object of class.

Or in other words...
How to spawn an actor declared in class. (actor is declared like the example of CAF)

behavior calculator_fun() {
  return {
    [](add_atom, int a, int b) { return a + b; },
    [](sub_atom, int a, int b) { return a - b; },
  };
}



Dominik Charousset

unread,
Nov 30, 2021, 4:59:34 AM11/30/21
to actor-f...@googlegroups.com
If you just want to have access to the actor itself, your function can take a self pointer (usually of type event_based_actor*).

To get into more details about class vs. function-based actors, I suggest reading this article: https://www.cafcademy.com/articles/implementing-actors-part-1 (and part2 as a followup).

    Dominik

Reply all
Reply to author
Forward
0 new messages