Ah yeah that’s great, that should solve the concurrency problems (although it will only allow 1 function call to go at once with that of course).
It won’t solve the context problem in blueprint, as in, if you need to use a variable or parameter after a function call (or after any latent/delay blueprint really), then it could either be overwritten already, or in the case of Objects, they could be garbage collected (and thus, be “invalid” / null). If you don’t use any variables or parameters after a function call, then this is something you won’t have to deal with.
Just as an example, in my code, I always use Latent Action objects to let the caller be able to wait for the function call (kinda like a Promise in javascript for example). For example, my code looks like this:
Calling code (click the thumbnail below for a larger image)
Wrapper around the network function/event (click the thumbnail below for a larger image)
The network function/event (click the thumbnail below for a larger image)
Now, in my network event, I have the Latent Action as a parameter (as well as a String in this example), both the Latent Action as well as the String are used after the function call is done.
If this network event is called twice before the function call has ended, it will override the Latent Action, as well as the String, and then the application will bug (it will hang in my demo game).
I prevented this by not allowing any user interaction for as long as a Latent Action is waiting to be finished anywhere (which is what my demo game functions “Start Loading” and “Stop Loading” do).
I did this because I didn’t see a proper way to handle function/event context before, but now, it’s clear that instead of just having the network function/event there, I should have placed it in a class, and gave that class a Latent Action and a String variable, and then just set those before calling a function/event inside of that class (that would run the function call inside of the class then).
If you’re having similar problems (or anyone else reading this), and I think this problem is somewhat common with network code, then this is the solution that will solve the concurrency as well as the context problem in blueprint. I hope it will help you in case you’re running into something similar to this as well at one point.