-
Notifications
You must be signed in to change notification settings - Fork 1
feature/contextwindowclosedcheck #1
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
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| taskContext.markClosed(); | ||
|
|
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.
Unnecessary new lines.
|
|
||
| throw new CompletionException(e); | ||
| } finally { | ||
| taskContext.markClosed(); |
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.
You should be careful with finally-blocks, since they are always executed, meaning #markClosed is executed twice in some cases.
| @Override | ||
| public void checkUse() { | ||
| if (closed) { | ||
| throw new IllegalStateException("TaskContext used after task finished"); | ||
| } | ||
|
|
||
| if (Thread.currentThread() != owner) { | ||
| throw new IllegalStateException("TaskContext used from non-owner thread"); | ||
| } | ||
| } |
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.
Are you sure you want exceptions to be thrown in the default case?
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.
yes, this method will be overriden in dirtcore
|
|
||
| @Override | ||
| public @NonNull Session session() { | ||
| this.checkUse(); |
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.
Keep in mind that this will not always work and is easily bypassed. Example:
Session session = context.session();
context.queue(() -> {
// do something involving the session
});
This ^ is how I usually structure my code.
AlphaConqueror
left a comment
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.
Take a look at the comments, generally fine.
No description provided.