25 lines
457 B
Go
25 lines
457 B
Go
|
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
|
||
|
}
|