concurrency

package
v2.0.9 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: MIT Imports: 2 Imported by: 2

Documentation

Overview

Package concurrency contain some functions to support concurrent programming. eg, goroutine, channel, async.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
}

Channel is a logic object which can generate or manipulate go channel all methods of Channel are in the book tilted《Concurrency in Go》

func NewChannel

func NewChannel() *Channel

NewChannel return a Channel instance

func (*Channel) Bridge

func (c *Channel) Bridge(ctx context.Context, chanStream <-chan <-chan any) <-chan any

Bridge link multiply channels into one channel

func (*Channel) FanIn

func (c *Channel) FanIn(ctx context.Context, channels ...<-chan any) <-chan any

FanIn merge multiple channels into one channel

func (*Channel) Generate

func (c *Channel) Generate(ctx context.Context, values ...any) <-chan any

Generate a data of type any chan, put param `values` into the chan

func (*Channel) Or

func (c *Channel) Or(channels ...<-chan any) <-chan any

Or read one or more channels into one channel, will close when any readin channel is closed

func (*Channel) OrDone

func (c *Channel) OrDone(ctx context.Context, channel <-chan any) <-chan any

OrDone read a channel into another channel, will close until cancel context.

func (*Channel) Repeat

func (c *Channel) Repeat(ctx context.Context, values ...any) <-chan any

Repeat return a data of type any chan, put param `values` into the chan repeatly until cancel the context.

func (*Channel) RepeatFn

func (c *Channel) RepeatFn(ctx context.Context, fn func() any) <-chan any

RepeatFn return a chan, excutes fn repeatly, and put the result into retruned chan until close the `done` channel

func (*Channel) Take

func (c *Channel) Take(ctx context.Context, valueStream <-chan any, number int) <-chan any

Take return a chan whose values are tahken from another chan

func (*Channel) Tee

func (c *Channel) Tee(ctx context.Context, in <-chan any) (<-chan any, <-chan any)

Tee split one chanel into two channels

Jump to

Keyboard shortcuts

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