From 13f7922e9a75b155f00638e252d7563a4f0cc541 Mon Sep 17 00:00:00 2001 From: VaclavT Date: Sun, 7 Nov 2021 12:31:48 +0100 Subject: [PATCH] thread under lock fixed --- ml.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ml.cpp b/ml.cpp index f02b0d2..0c09547 100644 --- a/ml.cpp +++ b/ml.cpp @@ -1954,7 +1954,7 @@ MlValue thread_create(std::vector 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 args, MlEnvironment &env) { } MlValue thread_under_lock(std::vector 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 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;