lang: Add mutex around Expr String/Value/SetValue calls

The golang race detector complains about some unimportant races, and as
a result, this patch adds some mutexes to prevent these test failures.
We actually lock more than necessary, because a more accurate version
would be more time consuming to implement. Secondarily, it's likely that
in the future we replace this function graph algorithm with something
that is guaranteed to be glitch-free and supports back pressure.
This commit is contained in:
James Shubin
2018-03-27 15:30:59 -04:00
parent 06ee05026b
commit 8500339ba6
4 changed files with 57 additions and 10 deletions

View File

@@ -93,6 +93,7 @@ func runInterpret(code string) (*pgraph.Graph, error) {
return errwrap.Wrapf(lang.Close(), "close failed")
}
// we only wait for the first event, instead of the continuous stream
select {
case err, ok := <-lang.Stream():
if !ok {
@@ -103,7 +104,7 @@ func runInterpret(code string) (*pgraph.Graph, error) {
}
}
// run artificially without the entire engine
// run artificially without the entire GAPI loop
graph, err := lang.Interpret()
if err != nil {
err := errwrap.Wrapf(err, "interpret failed")