-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add script termination option to 'Lua Scripts' floater #1152
Conversation
Maxim, thanks, I'm looking, but it will probably be tomorrow before I can respond. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you're still working on this, so maybe my comments have become moot. But there are a couple things in this PR as it now stands that I'd like to see changed.
@@ -429,6 +429,7 @@ void LLApp::setStatus(EAppStatus status) | |||
statsd = LLSD::Integer(status); | |||
} | |||
LLEventPumps::instance().obtain("LLApp").post(llsd::map("status", statsd)); | |||
LLEventPumps::instance().obtain("LLLua").post(llsd::map("status", "close_all")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Starting to look at this made me realize that I want to write a mechanism to request termination of an arbitrary C++ coroutine, not just one running Lua.
Quick sketch: I want to add a new data structure indicating a terminate request to LLCoros
, plus an LLEventStream
. The LLCoros
constructor will cause its "LLCoros"
LLEventPump
to listen on "LLApp"
so that events posted to "LLApp"
will be passed along on "LLCoros"
.
I'll make LLCoros::checkStop()
check for a termination request for this specific coroutine, in addition to checking for general viewer shutdown.
There are a few different places where a coroutine listens on "LLApp"
for viewer shutdown events. I'll change those to listen on "LLCoros"
instead.
The point of the distinction is that then I can resurrect the commented-out LLCoros::kill()
method to set a termination request for the subject coroutine. But in case the subject coroutine is waiting for an event, kill()
will also post a heads-up event on "LLCoros"
to cause each waiting coroutine to check for a termination request. I'd rather not post that event on the more generic "LLApp"
event pump.
So what I think I'd like to do is to accept this PR (once you're done; I realize you're still refining it) and then recast it to use the termination mechanism described above. I'll probably remove this second post()
call at that time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest I missed the ability to terminate coroutine once or twice in the past when working on maint bugs. So, I'm for it.
I'm not planning any more changes for now for this PR. (there will be some changes related to script termination as you know, but I'll create separate pr)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry to say I overlooked an important point. I can indeed introduce a flag for the next time a given coroutine wakes up and calls LLCoros::checkStop()
, but I can't cause that coroutine to wake up and check it. An LLEventStream
listener runs on the coroutine calling post()
. An exception thrown by such a listener will propagate through the post()
call.
The Boost.Fiber library we use does not provide a way to force an exception onto a suspended fiber -- although tantalizingly, the Boost.Context library on which it's based provides a mechanism that could support that. At present, the best we can do is to wait for the subject coroutine to call checkStop()
.
876196e
to
396ae60
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Maxim!
Add the way to terminate selected script in 'Lua Scripts' floater: call
lluau::error
when it's needed (but if the script is blocked ingetNext()
, close the queue first).