diff --git a/continuation.go b/continuation.go new file mode 100644 index 0000000..2ab6c80 --- /dev/null +++ b/continuation.go @@ -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 +}