Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBuffer ¶
func NewBuffer() (b *buffer)
NewBuffer returns a buffer with omitLF set to true - suitable for use as a standalone buffer.
Types ¶
type Buffer ¶
type Buffer interface {
Send(...string)
Append(...string)
Silent(bool) bool
Len() int
Deliver(w ...io.Writer)
}
Buffer allows a buffer to be embedded in a struct without exposing buffer itself. A buffer can be created and assigned using NewBuffer.
type Msg ¶
type Msg struct {
Actor *buffer
Participant *buffer
Observer *buffer
Observers buffers
}
Msg is a collection of buffers for gathering messages to send back as a result of processing a command. Before use a Msg should have Allocate called on it to allocate and setup the buffers internally. After use Deallocate should be called to free up the buffers. The Allocate and Deallocate methods are kept separate so that a Msg can be reused by repeated calls to Allocate/Deallocate.
NOTE: Observer is setup as an 'alias' for Observers[s.where] - Observer and Observers[s.where] point to the same buffer. See the Allocate method for more details.
func (*Msg) Allocate ¶
Allocate sets up the message buffers for the actor, participant and observers. The 'where' passed in should be the current location so that Observer can be linked to the correct Observers element. The locks passed in are used to setup a buffer for observers in each of the locations being locked.
The actor's buffer is initially set to half a page (half of 80 columns by 24 lines) as it is common to be sending location descriptions back to the actor. Half a page is arbitrary but seems to be reasonable.
NOTE: For crowded locations buffers of observers are automatically put in silent mode.
Source Files
¶
- buffer.go
- buffers.go
- msg.go