ctxsync

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

README

Package cloudeng.io/sync/ctxsync

CircleCI Go Report Card

import cloudeng.io/sync/ctxsync

Package ctxsync provides context aware synchronisation primitives.

Types

Type WaitGroup
type WaitGroup struct {
	sync.WaitGroup
}

WaitGroup represents a context aware sync.WaitGroup

Methods
func (wg *WaitGroup) Wait(ctx context.Context)

Wait blocks until the WaitGroup reaches zero or the context is canceled, whichever comes first.

Examples

ExampleWaitGroup

Documentation

Overview

Package ctxsync provides context aware synchronisation primitives.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WaitGroup

type WaitGroup struct {
	sync.WaitGroup
}

WaitGroup represents a context aware sync.WaitGroup

Example
package main

import (
	"context"
	"fmt"
	"time"

	"cloudeng.io/sync/ctxsync"
)

func main() {
	var wg ctxsync.WaitGroup
	wg.Add(1)
	ctx, cancel := context.WithCancel(context.Background())
	go func() {
		time.Sleep(time.Second)
		cancel()
	}()
	wg.Wait(ctx)
	fmt.Println(ctx.Err())
}
Output:

context canceled

func (*WaitGroup) Wait

func (wg *WaitGroup) Wait(ctx context.Context)

Wait blocks until the WaitGroup reaches zero or the context is canceled, whichever comes first.

Jump to

Keyboard shortcuts

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