-
Notifications
You must be signed in to change notification settings - Fork 869
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
Conversation
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.
Thank you for PR! I left couple of comments for possible enhancement (and my personal preferences). Could you check them out?
src/asio_client_session.cc
Outdated
} | ||
|
||
nghttp2_priority_spec_init(&spec_, spec_.stream_id, spec_.weight, | ||
spec_.exclusive); |
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.
I think it would be a bit nicer to do this in ctor, rather than here.
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.
sounds good to me!
src/asio_client_session.cc
Outdated
} | ||
|
||
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) |
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.
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.
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.
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.
src/asio_client_session.cc
Outdated
: valid_(true) { | ||
spec_.weight = weight; | ||
spec_.stream_id = stream_id; | ||
spec_.exclusive = exclusive; |
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.
I think these 3 lines can be removed. nghttp2_priority_spec_init basically does that.
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.
whoops! meant to remove that. thanks for catching.
Thank you! Merged now. |
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 samenullptr
argument tonghttp2_submit_request
(i.e. no specified priority), but when properly constructed, would pass annghttp2_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!