feat: add simple continuation implementation

This commit is contained in:
Jeremy Tregunna 2025-02-14 10:40:04 -06:00
parent aa2f6d371d
commit c040ab5636
No known key found for this signature in database
GPG Key ID: 1278B36BA6F5D5E4

24
continuation.go Normal file
View File

@ -0,0 +1,24 @@
package continuation
type Continuation struct {
result interface{}
err error
doneChan chan struct{}
}
func NewContinuation() *Continuation {
return &Continuation{
doneChan: make(chan struct{}),
}
}
func (c *Continuation) Resume(result interface{}, err error) {
c.result = result
c.err = err
close(c.doneChan)
}
func (c *Continuation) Wait() (interface{}, error) {
<-c.doneChan
return c.result, c.err
}