Hi
I have been trying to think of a way to properly integrate scripting inside a CAF system. Let's say Lua via sol3 C++ binding (but could be any scripting engine really).
I imagine a system here you have an actor that can receive a message to launch a script. The script in turn runs inside this actor meaning that if you bind methods to send messages via the script actor then CAF will have problems processing those messages since the actor is stuck processing a single event (LaunchScriptAtom). This leads to a situation where the script waits for a message that never arrives:
Launch script actor->script actor runs script->script calls c++ method->method sends message, waits for reply.
What would be a good way to design this so that an actor can run a script that can in turn participate in message sending? I can imagine it working by simply using blocking calls everywhere (make_function_view or so) but I am more interested in having messages be asynchronous.
I am imagining a script that can do something like this:
"
textFileFuture = async_load_text_file("/foo.txt") -- textFileFuture is a std::future<std::string>
-- do other stuff
textFile = textFileFuture.get() -- textFile is an std::string
"
Thank you