node-astar icon indicating copy to clipboard operation
node-astar copied to clipboard

async version

Open andrewrk opened this issue 12 years ago • 5 comments

andrewrk avatar Feb 06 '13 02:02 andrewrk

I've got a local promise-based asynchronous version using Q, but it'd take a little finagling to let it share the same implementation with the synchronous version. I don't think A* needs to be synchronous though because it's so slow. Word?

erisdev avatar Sep 20 '13 03:09 erisdev

:point_right: erisdiscord@4599ca526517a199a5b629f6eef73a4b5620a6ba

erisdev avatar Sep 20 '13 04:09 erisdev

that's cool that it doesn't eat the event loop, but it's still doing the processing in the main thread. It's not really a satisfying solution.

At least this sync version can be used with browser games, for example.

andrewrk avatar Sep 20 '13 04:09 andrewrk

I think it's good enough for cases where you just don't want to block (think of mineflayer, where a poorly timed pathfinding operation could result in a connection timeout). Agree that it's not ideal.

Q.js works in the browser too—you'd just need to replace setImmediate(iterate) in my branch with setTimeout(iterate, 0). I suppose I can see your point, though. I could probably throw together a callback-based interface that could be called synchronously.

erisdev avatar Sep 20 '13 04:09 erisdev

It's a hard problem. I agree that your version works better than a pure sync version like this in some use cases.

andrewrk avatar Sep 20 '13 04:09 andrewrk