Skip to content

ConnorDoyle/promise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!