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[T any]() (writer *MailboxWriter[T], reader *MailboxReader[T])
Types ¶
type MailboxReader ¶
type MailboxReader[T any] struct { // contains filtered or unexported fields }
do not attempt to access the same reader from >1 go-routine
func (*MailboxReader[T]) IsEmpty ¶
func (self *MailboxReader[T]) IsEmpty() (empty bool)
For use by the reader go-routine only. Returns true iff the mailbox is currently empty.
func (*MailboxReader[T]) Length ¶
func (self *MailboxReader[T]) Length() (length int)
For use by the reader go-routine only
func (*MailboxReader[T]) Receive ¶
func (self *MailboxReader[T]) Receive() T
For use by the reader go-routine only.
func (*MailboxReader[T]) Terminate ¶
func (self *MailboxReader[T]) Terminate()
Used by the reader to indicate the reader has exited. It is idempotent.
type MailboxWriter ¶
type MailboxWriter[T any] struct { TerminatedChan <-chan struct{} // contains filtered or unexported fields }
a writer can be safely used across multiple go routines
func (*MailboxWriter[T]) Send ¶
func (self *MailboxWriter[T]) Send(msg T) (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[T]) WaitForTermination ¶
func (self *MailboxWriter[T]) WaitForTermination()
Click to show internal directories.
Click to hide internal directories.