mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Fix thread::status() incorrect returning value
This commit is contained in:
parent
67116a67f9
commit
92f4c4c053
@ -173,11 +173,15 @@ namespace sol {
|
|||||||
|
|
||||||
thread_status status() const {
|
thread_status status() const {
|
||||||
lua_State* lthread = thread_state();
|
lua_State* lthread = thread_state();
|
||||||
thread_status lstat = static_cast<thread_status>(lua_status(lthread));
|
auto lstat = static_cast<thread_status>(lua_status(lthread));
|
||||||
int stacksize = lua_gettop(lthread);
|
if (lstat == thread_status::ok) {
|
||||||
if (lstat != thread_status::ok && lstat != thread_status::yielded && stacksize == 0) {
|
lua_Debug ar;
|
||||||
// No thing on the basic_thread's stack means its dead
|
if (lua_getstack(lthread, 0, &ar) > 0)
|
||||||
return thread_status::dead;
|
return thread_status::ok;
|
||||||
|
else if (lua_gettop(lthread) == 0)
|
||||||
|
return thread_status::dead;
|
||||||
|
else
|
||||||
|
return thread_status::yielded;
|
||||||
}
|
}
|
||||||
return lstat;
|
return lstat;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user