thread under lock fixed
This commit is contained in:
parent
a5a0029341
commit
13f7922e9a
8
ml.cpp
8
ml.cpp
|
|
@ -1954,7 +1954,7 @@ MlValue thread_create(std::vector<MlValue> args, MlEnvironment &env) {
|
|||
for (size_t i = 0; i < args.size(); i++)
|
||||
MlValue acc = args[i].eval(env);
|
||||
} catch (std::exception &e) {
|
||||
std::cerr << "thread exception: " << e.what() << std::endl;
|
||||
std::cerr << "thread_create exception: " << e.what() << std::endl;
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
|
@ -1974,15 +1974,15 @@ MlValue thread_create(std::vector<MlValue> args, MlEnvironment &env) {
|
|||
}
|
||||
|
||||
MlValue thread_under_lock(std::vector<MlValue> args, MlEnvironment &env) {
|
||||
if (args.size() != 2)
|
||||
throw MlError(MlValue("thread_under_lock", thread_under_lock), env, args.size() > 2 ? TOO_MANY_ARGS : TOO_FEW_ARGS);
|
||||
if (args.size() < 2)
|
||||
throw MlError(MlValue("thread_under_lock", thread_under_lock), env, TOO_FEW_ARGS);
|
||||
|
||||
if (args[0].as_string() != "ilock")
|
||||
throw MlError(MlValue("thread_under_lock", thread_under_lock), env, UNKNOWN_ERROR);
|
||||
|
||||
std::lock_guard<std::mutex> lockGuard(interpreter_mutex);
|
||||
MlValue acc;
|
||||
for (size_t i = 0; i < args.size(); i++)
|
||||
for (size_t i = 1; i < args.size(); i++)
|
||||
acc = args[i].eval(env);
|
||||
|
||||
return acc;
|
||||
|
|
|
|||
Loading…
Reference in New Issue