-*- Mode: Text, Spell -*- Ideas for a new slave/editor interface. Observation: most of the activity is output from the slave going directly into the editor buffer. When looking at the actual number of bytes transfered, another contender is chunks of text to be fed to compile-stream. Therefore, raw text should be as cheap as possible. For simplicity, the connection should be symmetrical. In other words, at the implementation level there shouldn't really be any difference between the slave->editor connection and the editor->slave connection. Idea: a CONNECTION structure describes the local side and is connected to the other process via a TCP/IP socket. Associated with the connection are any number of streams, only one of which is active at a time. Two things can be sent across a connection: messages and text. Messages are separate from the streams, while text is just forwarded to the active stream. Messages can be used to for RPCs, where all the data is contained directly in the message. If a large amount of data needs to be transfered, a new stream should be set up via an initiate message and used for the bulk of the data. When output is sent to a stream that isn't active, a special escape message is sent across in order to change the notion of the currently active stream. The policy used to decide when to change active streams should be tuned such that if several streams are trying to pass text the switching overhead will be minimal and no stream will starve. ;;;; Connection implementation details. Each connection needs the following information: - the socket - the user message handler - vector mapping remote output stream ids to handler functions. - the currently active input stream - ring of output streams who want to output - the currently active output stream (i.e. head of above ring) Each output stream has: - pointer to associated connection - stream id - fifo of buffers holding output that hasn't been sent yet. - buffer holding output as it accumulates (up until a force-output) note: the buffer already has the escape char escaped. Each buffer has: - a sap, a head, and a tail - a reference count Each input stream has: - fifo of buffers holding input that has arived but hasn't been read yet. - EOF flag indicating the EOF is after the last buffer in the fifo.