Ian,
I'm not trying to pick a fight, and I"m sorry if it seemed that way. I just want to make sure you know where I'm coming from, since you seemed to be objecting to some of the changes Brian was making on my behalf. I think we're actually pretty much on the same page here. I agree spamming Mach with JogOffs is not good, and it was inadvertent, but who would've ever guessed it would cause G31 to misbehave???
I certainly never suggested doing away with concurrency, but right now, you get it whether you want it or not, and protecting yourself from it often takes a LOT of effort, and, as I'm finding, sometimes even then is not possible to make it really bullet-proof. That's exactly the opposite of the way it should be. Operation should be simple, obvious even, and robust, so even a newbie can make basic operations work easily. Then, if you WANT multiple threads and concurrency, a means of getting it should be provided, but ONLY when asked for. That way, it works easily for the novices, and it provides the advanced features us more advanced users want. Everyone wins. But now, trying to take advantage of seemingly simple and straight-forward functions can lead to hours of needless debugging. One thing I've learned in 30+ years of designing chips, boards, and software for complex systems is: If it's complicated, you haven't designed it right. When debugging becomes like squeezing a balloon, and making a small change in one area makes something in a seemingly unrelated area break, then you're working with a badly architected system.
Yes, now that I truly understand how G-code makes it from a script into the motion engine, I would absolutely surround every, single G-code command with While Ismoving loops. Years ago, when I wrote that code (That was actually my very first Mach3 macro), I foolishly believed that G-code commands all went into the same execution queue, and would, at least, always be executed in order. Silly me! I also thought IsMoving would actually indicate that the machine was moving, and not simply that there were still G-code commands waiting in the buffer, and would have no meaning when executing a G90! Where do I get these crazy ideas? :-)
Regards,
Ray L.