-
Notifications
You must be signed in to change notification settings - Fork 519
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
Bukkit thread safety checks and fixes #1992
base: master
Are you sure you want to change the base?
Conversation
This would have worked out well as two pull requests—one fixing the issues you've found, and the other one with the more "experimental" feature of annotating methods / ensuring their usages. My problem with the annotations is that it needs to be clear what they represent and when they have to be used, so that they can be maintained and kept up-to-date in the future. For example, |
Yes, but i really needed that annotations to be able to keep track of what needs to be called by the main thread and what needs to be called async. |
To be honest i just really don't like it because of how spammy it is in the code. You can merge it if you want since I've anyway taken a bit more of a background role lately. I just really don't think the benefits outweigh the pain of understanding the annotations (not even going to mention the MightBeAsync name for the third time). I just think some things aren't really meant to be verified programmatically because it just doesn't... add up. This is prone to become inconsistent, or already is. For example: a protected method annotated with Edit: What does even |
Atm we have no way to know if a method needs to be thread-safe, or if it is a blocking operation, this PR tries to add source annotation to help developers remember that. |
This comment addresses none of the points I brought up. |
Note for myself |
I would like to have an input from the other members of the team also, so we can find the better solution for this issue. |
I kind of understand both of your points. I think this idea can be useful, because it would allow us to verify the asynchronous usage. However the current state can be very misleading.
I agree. Therefore I think those annotations have to be documented including their motivation. Maybe it's also necessary to write a small developer introduction like in a
I think Sync and Async are enough too. Having optionally async makes the situation very complex. Either it should run asynchronous, because it has to be or not.
Good point. Maybe something like
Our current approach is to fetch data asynchronously and then continue in this context. Taking this quoted segment further means we would to it only on heavy operations. This would allow us to reduce the number of possible thread unsafe code greatly. I'm thinking here a NodeJS similar concept:
Specifically we could use something like the TaskChain project. This would make the current code thread-safe to the Bukkit API and less complex. However requires a lot of refactoring if we consider the old code too. So I don't know how useful this can be. |
BTW: Android has a similar concept. They use annotations ( It shows some points that I noticed during my usage in
|
No description provided.