xsync

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

README

xsync

simple and powerful sync package

example

package main

import (
	"fmt"
	"time"

	"github.com/adwpc/xsync"
)

func main() {
    swg := xsync.NewXWaitGroup()
	swg.Add(1)
	go func() {
		time.Sleep(5 * time.Second) // simulate a long task
		swg.Done()
	}()
	// swg.Done() // extra Done call, will not cause panic
	if swg.Wait(3 * time.Second) {
		fmt.Println("Timed out")
	} else {
		fmt.Println("XWaitGroup finished")
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type XWaitGroup

type XWaitGroup struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewXWaitGroup added in v0.1.1

func NewXWaitGroup() *XWaitGroup

func (*XWaitGroup) Add

func (swg *XWaitGroup) Add(delta int)

func (*XWaitGroup) Done

func (swg *XWaitGroup) Done()

func (*XWaitGroup) Wait

func (swg *XWaitGroup) Wait(timeout time.Duration) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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