Homepage: https://www.gnu.org/software/emacs
Author: Scott Draves
Utility to maintain a transaction queue
This file manages receiving a stream asynchronously, parsing it into transactions, and then calling the associated handler function upon the completion of each transaction. Our basic structure is the queue/process/buffer triple. Each entry of the queue part is a list of question, regexp, closure, and function that is consed to the last element. A transaction queue may be created by calling `tq-create'. A request may be added to the queue by calling `tq-enqueue'. If the `delay-question' argument is non-nil, we will wait to send the question to the process until it has finished sending other input. Otherwise, once a request is enqueued, we send the given question immediately to the process. We then buffer bytes from the process until we see the regexp that was provided in the call to `tq-enqueue'. Then we call the provided function with the closure and the collected bytes. If we have indicated that the question from the next transaction was not sent immediately, send it at this point, awaiting the response.