Skip to content

Async compilation or cancellation support #216

Description

@AngryCarrot789

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions