feat: add simple continuation implementation
This commit is contained in:
parent
aa2f6d371d
commit
c040ab5636
24
continuation.go
Normal file
24
continuation.go
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user