Skip to content

Commit

Permalink
document generics in readme (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
miparnisari authored Feb 18, 2024
1 parent a980655 commit 3037838
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
[![GoDoc](https://godoc.org/resenje.org/singleflight?status.svg)](https://godoc.org/resenje.org/singleflight)
[![Go](https://github.com/janos/singleflight/workflows/Go/badge.svg)](https://github.com/janos/singleflight/actions?query=workflow%3AGo)

Package singleflight provides a duplicate function call suppression
mechanism similar to [golang.org/x/sync/singleflight](https://pkg.go.dev/golang.org/x/sync/singleflight) but with support
for context cancelation. The context passed to the callback function is a context that preserves all values
from the passed context but is cancelled by the singleflight only when all
awaiting caller's contexts are cancelled.
Package singleflight provides a duplicate function call suppression
mechanism similar to [golang.org/x/sync/singleflight](https://pkg.go.dev/golang.org/x/sync/singleflight) but with:

- support for context cancelation. The context passed to the callback function is a context that preserves all values
from the passed context but is cancelled by the singleflight only when all awaiting caller's contexts are cancelled.
- support for generics.

## Installation

Expand Down
2 changes: 2 additions & 0 deletions singleflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (

// Group represents a class of work and forms a namespace in
// which units of work can be executed with duplicate suppression.
// K is the type of the key used for deduplication, and V is
// the return value of the work function.
type Group[K comparable, V any] struct {
calls map[K]*call[V] // lazily initialized
mu sync.Mutex // protects calls
Expand Down

0 comments on commit 3037838

Please sign in to comment.