co

package
v0.0.0-...-e4e12f0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2022 License: LGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parallel

func Parallel(cb func(chan<- func())) <-chan struct{}

Parallel to run a batch of work using as many CPU as it can.

Types

type Goes

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

Goes to run and manage life-cycle of go routines.

func (*Goes) Done

func (g *Goes) Done() chan struct{}

Done return the done channel for exiting of all go routines.

func (*Goes) Go

func (g *Goes) Go(f func())

Go run f in go routine.

func (*Goes) Wait

func (g *Goes) Wait()

Wait wait for all go routines started by 'Go' done.

type Signal

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

Signal a rendezvous point for goroutines waiting for or announcing the occurrence of an event. It's more friendly than sync.Cond, since it's channel base. That means you can do channel selection to wait for an event.

func (*Signal) Broadcast

func (s *Signal) Broadcast()

Broadcast wakes all goroutines that are waiting on s.

func (*Signal) NewWaiter

func (s *Signal) NewWaiter() Waiter

NewWaiter create a Waiter object for acquiring channel to wait for.

func (*Signal) Signal

func (s *Signal) Signal()

Signal wakes one goroutine that is waiting on s.

type Waiter

type Waiter interface {
	C() <-chan bool
}

Waiter provides channel to wait for. Value read from channel indicates signal or broadcast. true for signal, otherwise broadcast.

Jump to

Keyboard shortcuts

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