Gcode sender programming is really out of scope for this tinyG user Forum.
Xon/Xoff has been around for a long time, and is usually handled by the serial driver layer. Are you planning to develop the entire sender, including the serial I/O handler? Big job, timing is critical. You could also use RTS/CTS (hardware) flow control.
You ask about queue based flow management. The only implementation I have heard of is Chilipeppr and the SPJS(serial port json server). It is all open source, but way beyond a “snipet” in scope and complexity
Good luck with your project.