Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 772 Bytes

README.md

File metadata and controls

32 lines (23 loc) · 772 Bytes

promise

Build Status

GoDoc

Promise is a disposable write-once latch, to act as a synchronization barrier to signal completion of some asynchronous operation (successful or otherwise).

Functions that operate on this type (IsComplete, Complete, Await, AwaitUntil) are idempotent and thread-safe.

Minimal example

package main

import (
	"fmt"
	"github.com/ConnorDoyle/promise"
)

func main() {
	p := promise.New()
	go p.Complete(nil)
	p.Await()
	fmt.Println("goroutine ran")
}

...and never rely on Sleep in test code again!