An open API service indexing awesome lists of open source software.

https://github.com/samthor/inc

tiny golang version helper
https://github.com/samthor/inc

Last synced: about 2 months ago
JSON representation

tiny golang version helper

Awesome Lists containing this project

README

          

Provides `Inc`, a helper for concurrent Go applications.

Each instance encapsulates an always-increasing `time.Time` as a monotonically increasing version number.
Clients can wait for the version to change.

Good usages for this object are to guard some external state, e.g., the current state of physical sensors where history is not important.

## Usage

Basic, direct usage.

```go
i := inc.New()

// on one goroutine
var ver time.Time
ver = i.Wait(ver, nil)

// on another goroutine
i.Update()
```

Use with channels.

```go
update, cancel := i.Pend(ver)
ver = <-update // read next version
```