mailbox

package
v0.0.0-...-d11619d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2022 License: Apache-2.0 Imports: 1 Imported by: 3

Documentation

Overview

Every Mailbox is safe for multiple concurrent writers, and one reader. It is unbounded in length.

Index

Constants

View Source
const InitialMsgChanLen = 16

Variables

This section is empty.

Functions

func NewMailbox

func NewMailbox() (writer *MailboxWriter, reader *MailboxReader)

Types

type MailboxReader

type MailboxReader struct {
	// contains filtered or unexported fields
}

do not attempt to access the same reader from >1 go-routine

func (*MailboxReader) IsEmpty

func (self *MailboxReader) IsEmpty() (empty bool)

For use by the reader go-routine only. Returns true iff the mailbox is currently empty.

func (*MailboxReader) Length

func (self *MailboxReader) Length() (length int)

For use by the reader go-routine only

func (*MailboxReader) Receive

func (self *MailboxReader) Receive() Msg

For use by the reader go-routine only.

func (*MailboxReader) Terminate

func (self *MailboxReader) Terminate()

Used by the reader to indicate the reader has exited. It is idempotent.

type MailboxWriter

type MailboxWriter struct {
	TerminatedChan <-chan struct{}
	// contains filtered or unexported fields
}

a writer can be safely used across multiple go routines

func (*MailboxWriter) Send

func (self *MailboxWriter) Send(msg Msg) (success bool)

returns false if the channel has been terminated. true indicates the msg has been sent, not that it's going to be received or processed.

func (*MailboxWriter) WaitForTermination

func (self *MailboxWriter) WaitForTermination()

type Msg

type Msg interface{}

type MsgChanCell

type MsgChanCell struct {
	// contains filtered or unexported fields
}

We form a linked-list of MsgChanCells.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL