sync

package
v0.0.97 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2021 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Subject

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

The caller typically cannot assume that the condition is true when Subscribe chan returns. Instead, the caller should Wait in a loop:

eventC, cancel := c.Subscribe()
for !condition() {
    select{
    case event, closed := <- eventC:
        ... make use of event ...
    }
}
... make use of condition ...

func (*Subject) PublishBroadcast

func (s *Subject) PublishBroadcast(ctx context.Context, event interface{})

PublishBroadcast wakes all listeners waiting on c.

func (*Subject) PublishSignal

func (s *Subject) PublishSignal(ctx context.Context, event interface{})

PublishSignal wakes one listener waiting on c, if there is any.

func (*Subject) Subscribe

func (s *Subject) Subscribe() (<-chan interface{}, context.CancelFunc)

Subscribe returns a channel that's closed when awoken by PublishSignal or PublishBroadcast. never be canceled. Successive calls to Subscribe return different values. The close of the Subscribe channel may happen asynchronously, after the cancel function returns.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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