Skip to content

Conversation

@KrzysztofCiborowski
Copy link
Member

No description provided.

Comment on lines +99 to +101

taskContext.markClosed();

Copy link
Member

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();
Copy link
Member

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.

Comment on lines +65 to +74
@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");
}
}
Copy link
Member

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?

Copy link
Member Author

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();
Copy link
Member

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.

Copy link
Member

@AlphaConqueror AlphaConqueror left a 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.

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

Successfully merging this pull request may close these issues.

3 participants