Prevent data races.

This commit is contained in:
Stephen Chung
2020-08-02 13:33:51 +08:00
parent 1daf91df30
commit b86c87253b
6 changed files with 124 additions and 6 deletions

View File

@@ -3,6 +3,7 @@
use crate::any::{Dynamic, Variant};
use crate::engine::{Engine, Imports, State};
use crate::error::ParseError;
use crate::fn_call::ensure_no_data_race;
use crate::fn_native::{IteratorFn, SendSync};
use crate::module::{FuncReturn, Module};
use crate::optimize::{optimize_into_ast, OptimizationLevel};
@@ -1282,6 +1283,11 @@ impl Engine {
let mut mods = Imports::new();
let args = args.as_mut();
// Check for data race.
if cfg!(not(feature = "no_shared")) {
ensure_no_data_race(name, args, false)?;
}
self.call_script_fn(
scope, &mut mods, &mut state, lib, this_ptr, name, fn_def, args, 0,
)