Skip to content
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

Implement requiresMainThread #8

Open
bluelhf opened this issue Jun 17, 2022 · 2 comments
Open

Implement requiresMainThread #8

bluelhf opened this issue Jun 17, 2022 · 2 comments

Comments

@bluelhf
Copy link
Contributor

bluelhf commented Jun 17, 2022

Is your feature request related to a problem? Please describe.
In its current state, the requiresMainThread setting for expressions is never respected. In fact, the term "requiresMainThread" only occurs twice in the entirety of the ByteSkript source code: once in SyntaxElement.java, where it is defined, and once in ExprSystemInput.java, which is the only built-in expression to use the feature.

Describe the solution you'd like
The requiresMainThread setting should cause not only the expression's compiled code but also its handlers to be wrapped using a mechanism that allows the code to run only on the main thread of execution.

Describe alternatives you've considered
Not applicable.

Additional context
Project maintainers are likely already aware of the lack of implementation for this feature. This issue is not a feature request per se, rather it is meant to express the demand for the feature along with sparking discussion regarding possible implementation details.

@Moderocky
Copy link
Owner

The idea of 'main thread' is ill-defined and not really applicable to the base language outside things like system input which requires being asked for from the console thread.

It's something that I expect offshoots to need (e.g. Bukkit things) but there's not a huge amount I can do to support it here since it's likely something that's very implementation-dependent.

@bluelhf
Copy link
Contributor Author

bluelhf commented Jun 19, 2022

After further consideration I believe that it may be best to leave synchronisation with the illusive "main thread" up to library maintainers: ByteSkript code cannot truly run on the main thread without some sort of task queue, which would block the main thread indefinitely. It is also not implicitly guaranteed that ByteSkript's main thread is actually the same as, or even synchronized with, the main thread of the library's host program (assuming the library maintainer does not make deliberate efforts to ensure this behaviour), so this feature may not be applicable even in the context of the aforementioned offshoots.

Pull request #9 addressed this issue, removing the requireMainThread method completely. As of now, both the method definition and its one usage in the project are commented out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants