tree: 9c2cddfb3828cbc4307d69d94b3a629b2734bbc0 [path history] [tgz]
  1. channel.go
  2. channel_id.go
  3. messages.go
  4. msg_type.go
  5. multiplexer.go
  6. multiplexer_binary.go
  7. multiplexer_test.go
  8. README.md
  9. send_map.go
  10. sender.go
multiplexer/README.md

multiplexer


import "android.googlesource.com/platform/tools/gpu/multiplexer"

Package multiplexer provides multiple data-stream multiplexing over a single binary data-stream.

Usage

var ErrChannelClosed = errors.New("Channel closed")

type Multiplexer

type Multiplexer struct {
}

Multiplexer provides multiple data-stream multiplexing over a single binary data-stream. Channels can be opened and closed by either endpoint, and data can be sent on an open channel in either direction. The muliplexer attempts to evenly distribute bandwidth between channels.

func New

func New(in io.Reader, out io.Writer, mtu int, channelOpenedCallback func(io.ReadWriteCloser)) *Multiplexer

New creates and returns a new Multiplexer using the specified reader and writer for communication. mtu defines the maximum size of each packet of data. channelOpenedCallback will be called for each channel that was opened by the remote endpoint.

func (*Multiplexer) MTU

func (m *Multiplexer) MTU() int

MTU returns the maximum transmission unit size the multiplexer was created with.

func (*Multiplexer) OpenChannel

func (m *Multiplexer) OpenChannel() (io.ReadWriteCloser, error)

OpenChannel opens a new channel for communication. This will invoke the the channel-opened callback on the remote endpoint.