lang: gapi, unification: Shutdown unification quickly when asked
This is a bit of a hack until we improve the GAPI a bit, but will let us shut down type unification a bit faster if we want to interrupt a long running operation. Hopefully our future algorthmic performance improvements will obliviate the need for this to be a common issue.
This commit is contained in:
@@ -503,6 +503,16 @@ func (obj *GAPI) Graph() (*pgraph.Graph, error) {
|
||||
|
||||
// Next returns nil errors every time there could be a new graph.
|
||||
func (obj *GAPI) Next() chan gapi.Next {
|
||||
// TODO: This ctx stuff is temporary until we improve the Next() API.
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
obj.wg.Add(1)
|
||||
go func() {
|
||||
defer obj.wg.Done()
|
||||
select {
|
||||
case <-obj.closeChan:
|
||||
cancel() // close the ctx to unblock type unification
|
||||
}
|
||||
}()
|
||||
ch := make(chan gapi.Next)
|
||||
obj.wg.Add(1)
|
||||
go func() {
|
||||
@@ -553,7 +563,7 @@ func (obj *GAPI) Next() chan gapi.Next {
|
||||
// run up to these three but fail on err
|
||||
if e := obj.LangClose(); e != nil { // close any old lang
|
||||
err = e // pass through the err
|
||||
} else if e := obj.LangInit(context.TODO()); e != nil { // init the new one!
|
||||
} else if e := obj.LangInit(ctx); e != nil { // init the new one!
|
||||
err = e // pass through the err
|
||||
|
||||
// Always run LangClose after LangInit
|
||||
|
||||
Reference in New Issue
Block a user