Thread safety, delegates and bPostTickComponentUpdate
So I'm using a hardware input device that runs its own thread (inside its own dll, that I have no source for unfortunately) and calls specific functions on a listener class I define. That listener class then in turn broadcasts the events through delegates to instances of an Actor Component, which themselves have delegates that can be listened to in Blueprint. However, when I actually run tests with this, I get assert failures in void
I'm going to go out on a limb here and say that it looks like I'm running into issues where the thread that the library is creating isn't interacting with my delegates and Blueprint in a thread-safe way, or at the least is broadcasting the delegate at the wrong points in the main loop. I tried to put a check for GetWorld()->bPostTickComponentUpdate into my code, just as a test, to see if this would help me synch my delegate invocations at the right point in time, but it didn't really seem to help.
Is there any information regarding thread safety with delegates/blueprint/actor ticking that I can look at, to avoid this?
asked Apr 16 '14 at 01:47 AM in C++ Programming
Actors can be only ticked on the game thread. I suggest using task graph task that will be executed on the game thread, then you are safe to call any delegates.
Here is a code snippet. You can use simple delegate task or write your own task.
I hope this will help you :)
answered Apr 18 '14 at 12:27 PM
You can pass all parameters in these tasks as in the regular delegate.
answered Apr 18 '14 at 07:34 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here