Skip to content

stephennancekivell/go-future

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-future

A concurrency library for go.

Also see the introductory blog post Simplifying go concurrency with Future

Install

go get github.com/stephennancekivell/go-future

Usage

Create a future with a function that you want to run in a go routine, get use .Get() to get the value, waiting for it if its not ready.

f := future.New(func() string {
    return "value"
})

value := f.Get()

If you have a list of futures you can transform them into a single Future with Sequence or Traverse

var someFutures []Future[T] // eg
f := future.Sequence(someFutures)

valuesSlice := f.Get()

If you have two futures and want the fastest result you can use can use Race.

var fa Future[T]
var fb Future[T]

f := future.Race(fa, fb)

fastestResult := f.Get()

About

A futures concurrency library in go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages