Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You could save the future in the Future implementation

    type future struct {
        completed   bool
        result      interface{}
        ch        <-chan interface{}
    }
Edit: Or just check if the channel is closed

    func (f *future) Wait() interface{} {
        v, ok := <- ch
        if ok { f.result = v; return v }
        else  { return f.result }
    }


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: