In the first pseudocode, the cooperative pathfinding thread unstoppingly producing waypoints for
the main thread to consume.
Because the mainthread will delete all waypoints in each iteration, it will get the latest waypoints
from the "CPF" thread, but this has a shortcoming, the mainthread will jerk as the it has to wait
for the cpf thread to compute something and provide him some waypoints.
Are there any good suggestions that I could make some improvements on this.
Should I just slow down the cpf thread, make him produce less waypoints,
and the mainthread will keep on interpolating on his current waypoints?
PS: A path point is a cell that the TimeAStar has reserved for the current window
And also, I am looking into something like conditional variables and futures of the std library.. right? :)
Thanks
Jack
cpf_thread_start:
cpf thread -> delete all pathpoints
cpf thread -> create pathpoints
cpf thread -> create waypoints 1,2,3,4,5,6
goto cpf_thread_start:
main:
mainthread -> delete all waypoints
mainthread -> consume next waypoint (wait for cpf thread to provide some)
mainthread -> Intepolating between 2 waypoints
goto main:
main)
waypoints empty
waypoints 1,2,3,4,5,6
waypoints empty
waypoints 2,3,4,5,6
waypoints empty
waypoints 3,4,5,6
The mainthread has to wait for the cpf thread to provide some waypoints
from each iteration