-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Make ResponseFuture
'static
#403
Comments
I'm interested in implementing this. Is it OK to remove the lifetime directly? We can clone the client everytime we create a response future. |
Creating a Internally the function that submits a request to the HTTP agent is called an isahc/src/interceptor/context.rs Lines 16 to 25 in 2cb2fe4
The invoker context is created and placed into an Lines 1031 to 1034 in 2cb2fe4
To make isahc/src/interceptor/context.rs Lines 6 to 10 in 2cb2fe4
to using indexes to keep track of which interceptor is the current one. That might look something like this: pub struct Context { // note that Context can now be 'static
pub(crate) client: HttpClient,
pub(crate) interceptor_offset: usize,
} As a side-effect, this refactoring may actually improve performance, since we won't need to heap-allocate an |
…ture (#405) This PR will fix #403 The benchmark seems can't reflect the actual improvement. (I guess the test case(64K) is not suitable to measure the different between an `Arc::new`) Before: ```shell download 64K: isahc time: [201.80 ms 204.40 ms 207.00 ms] ``` After ```shell download 64K: isahc time: [200.32 ms 203.57 ms 206.90 ms] ``` Signed-off-by: Xuanwo <github@xuanwo.io>
ResponseFuture
is currently not'static
because it borrows the client instead of doing an implicit clone, but this can be annoying to use with a program structure where you don't pass around the client. This can probably be done without any additional clones or boxing if we do some internal restructuring of the client, which already uses anArc
, such thatResponseFuture
can simply clone the same shared object that cloning anHttpClient
itself does.See also #401.
The text was updated successfully, but these errors were encountered: