In the guide the example you give is a Throttled Thread.
If I wanted the length of the tick in my thread to match the length of the tick in the GameThread what changes would I make to do so? Is there an easy change I could make to achieve this?
You could update the thread dynamically to match game thread, but if you are doing something where thread-synchronization is that sensitive you should probably reconsider your design architecture!
A very fast tick rate is 0.001, SUPER fast is 0.0001.
Keep in mind that 200 FPS
is 1/200 = 0.005 seconds
void ARamaCodeMultiThreadActor::JoyThread_Init()
{
//...
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Thread Tick Rate
//!!! MAKING THIS ENTIRE PROCESS GO SLOWLY OR QUICKLY
//!!! ATTENTION: COMPUTER RESOURCE MANAGEMENT DEPT OF YOUR GAME LOGICS
//!!! <3 RAMA
FTimespan ThreadWaitTime = FTimespan::FromSeconds(0.01); //! Use 0.1 or higher if don't need calcs to occur quickly!
Hi Rama! First, thank you a lot for everything you’ve done to the community. There are lots of people like me that grew on your tutorials!
Secondly, in my testing, this variable that you are changing doesn’t have an effect on the tick rate. I tested it like so:
Donwloaded your repository
Changed FTimespan ThreadWaitTime 10 times lower and 10 times higher. It didn’t make any difference.
Moreover judging by the code, your ThrottledThreadTime is only being used in one section of the code: FRamaCodePrimeCalcThread::JoyTick(), however this thing is never called during the generation of prime numbers, hence it doesn’t have any effect on the logic rather than initial delay.
I had changed my code to make sure a hitch would be visible and obvious if the threading did not get set up correctly.
In a realistic case, you would want to not do the entire loop in a single tick, also so that the thread uses less resources, while taking a little bit longer to complete.
Then the thread throttling will also take effect, if you do only a few of your calculations per tick.
Sorry, a little bit of tweaking required for a realistic case.
My video demonstrates a Gigantic calculation occurring in 1 single chunk, on another operating system level thread, to prove the multi threading is truly solid, and working