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

Support specifying stream priority via session::submit() #881

Merged
merged 1 commit into from
Apr 12, 2017
Merged

Support specifying stream priority via session::submit() #881

merged 1 commit into from
Apr 12, 2017

Conversation

mway
Copy link
Contributor

@mway mway commented Apr 11, 2017

i noticed that the C++ API doesn't pass along priority (just passes nullptr currently), so i thought a clean way to do this (without exposing the underlying nghttp2 types) would be to just create a simple wrapper that could be passed along, whose sentinel value would result in the same nullptr argument to nghttp2_submit_request (i.e. no specified priority), but when properly constructed, would pass an nghttp2_priority_spec*.

for convenience, it also seemed reasonable that priority_spec ctor should be easily usable by providing the most common arguments first, i.e., trivially used to represent weight (e.g. priority_spec(4.0)).

i need this on my end, so happy to make any adjustments you'd like!

Copy link
Member

@tatsuhiro-t tatsuhiro-t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for PR! I left couple of comments for possible enhancement (and my personal preferences). Could you check them out?

}

nghttp2_priority_spec_init(&spec_, spec_.stream_id, spec_.weight,
spec_.exclusive);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be a bit nicer to do this in ctor, rather than here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good to me!

}

void session::read_timeout(const boost::posix_time::time_duration &t) {
impl_->read_timeout(t);
}

priority_spec::priority_spec(int32_t weight, int32_t stream_id, int exclusive)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be nice to arrange the order of the parameter in the same order as nghttp2_priroty_spec_init, that is, stream_id, weight, and then exclusive.
Since exclusive is effectively boolean, I prefer bool type for exclusive to generic int.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah - i'd gone back and forth with consistency because it seemed like, for the simplest use, the weight would be the only specified parameter. but happy to keep it the same.

: valid_(true) {
spec_.weight = weight;
spec_.stream_id = stream_id;
spec_.exclusive = exclusive;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these 3 lines can be removed. nghttp2_priority_spec_init basically does that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops! meant to remove that. thanks for catching.

@tatsuhiro-t tatsuhiro-t merged commit a1bc83a into nghttp2:master Apr 12, 2017
@tatsuhiro-t
Copy link
Member

Thank you! Merged now.

@mway mway deleted the dev/request-priority branch April 25, 2017 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants