syncex

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Collect added in v0.0.3

func Collect(errchans ...<-chan error) <-chan error
Example
doWork := func(url string) chan error {
	errs := make(chan error)
	go func(url string) {
		// Some expensive work..
		_, err := http.Get(url)
		if err != nil {
			errs <- err
		}
	}(url)
	return errs
}

for err := range Collect(
	doWork("1"),
	doWork("2"),
) {
	if err != nil {
		fmt.Println("Error:", err)
	}
}
Output:

func CollectContext added in v0.0.3

func CollectContext(ctx context.Context, errchans ...<-chan error) <-chan error

Types

type Counter added in v0.0.4

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

func (*Counter) Add added in v0.0.4

func (c *Counter) Add(delta int64)

func (*Counter) Dec added in v0.0.4

func (c *Counter) Dec()

func (*Counter) Inc added in v0.0.4

func (c *Counter) Inc()

func (*Counter) Reset added in v0.0.4

func (c *Counter) Reset()

func (*Counter) Value added in v0.0.4

func (c *Counter) Value() int64

type Semaphore

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

func NewSemaphore

func NewSemaphore(initialCount int) *Semaphore

func (*Semaphore) Acquire

func (s *Semaphore) Acquire()

func (*Semaphore) AcquireTimeout

func (s *Semaphore) AcquireTimeout(timeout time.Duration) bool

func (*Semaphore) Release

func (s *Semaphore) Release()

Jump to

Keyboard shortcuts

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