feat(lua): throw an exception if the user tries to create a thread and Lean was compiled without multi-threading support
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
3a924a5fb1
commit
bd1e9c7548
2 changed files with 9 additions and 0 deletions
|
@ -399,6 +399,7 @@ leanlua_thread & to_thread(lua_State * L, int idx) {
|
|||
}
|
||||
|
||||
int mk_thread(lua_State * L) {
|
||||
check_threadsafe();
|
||||
leanlua_state & st = to_state(L, 1);
|
||||
char const * script = luaL_checkstring(L, 2);
|
||||
int first = 3;
|
||||
|
|
|
@ -62,4 +62,12 @@ public:
|
|||
void join();
|
||||
bool joinable();
|
||||
};
|
||||
|
||||
#ifdef LEAN_THREAD_UNSAFE
|
||||
inline void check_threadsafe() {
|
||||
throw exception("Lean was compiled without support for multi-threading");
|
||||
}
|
||||
#else
|
||||
inline void check_threadsafe() {}
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue