-
Notifications
You must be signed in to change notification settings - Fork 46
Description
Support for LuaCompiler.Compile() to take a cancellation token and to check for cancelled state would be useful.
It shouldn't have a huge impact, since CancellationToken.ThrowIfCancellationRequested() is cheap when using an uncancellable token (i.e. CancellationToken.None), but does require a volatile read when actually cancellable, but this is worth if it cancellation support is really needed.
Current workaround is to inline LuaSyntaxTree.Parse() and call LuaCompiler.Compile() directly, and check for cancellation everywhere, and I run this within a new thread.
If cancellation is actually requested, I mark my TaskCompletionSource as cancelled and just forget about the thread, which isn't great if it's compiling something complex and using an entire CPU core to do so, and the result will be ignored anyway.