Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To-Do
Things to improve (but not not required for merge)
About Astar
Astar is a popular pathfinding algorithm. It offers improvements over Dijkstra's original algorithm by extending its idea with an heuristic. The heuristic will 'direct the searching more likely towards the destination' rather than increasing the evaluated area 'circular' (in Dijkstra). This leads to much less evaluated nodes (in case the destination is reachable). This implementation here operates on grids with 8 adjacent squares and uses 'Octile' heuristic. Moving is not only limited by fully blocked squares, but also dependent on up to 8 different incoming and 8 different outgoing edges from each square to adjacent neighbours.
Caching
To improve the response times and keep calculations low, there are 3 kinds of caches implemented:
C++ 2011
This uses a couple of ::std classes, such as ::std::mutex, ::std::queue, ::std::map and others.
Except for a single 'PostThreadMessage()' in astar.c this is supposed to be fully linux compatible.
queue.h
This pull brings a new 'queue.h' file to blakserv. It contains a template class for a threadsafe queue as used in consumer&producer patterns. This could become handy for other tasks (for example the mysql module could be refactored using it).
Multithreading architecture
Multithreading is implemented based on a typical producer & consumer pattern. In this case blakserv is the producer of 'Queries' and the workers are the consumers of 'Queries'. On the other hand the workers are the producers of 'Responses' and the blakserv mainthread is the consumer of them. Both directions are fully asynchron and keep locking to a minimum.