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
- Host: GitHub
- URL: https://github.com/samthor/inc
- Owner: samthor
- License: apache-2.0
- Created: 2016-02-14T00:12:21.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-10-18T12:48:11.000Z (over 9 years ago)
- Last Synced: 2025-01-18T15:52:53.013Z (over 1 year ago)
- Language: Go
- Size: 10.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
```