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:
Leonardo de Moura 2013-11-14 19:06:36 -08:00
parent 3a924a5fb1
commit bd1e9c7548
2 changed files with 9 additions and 0 deletions

View file

@ -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;

View file

@ -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
}