mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Optimize mutex usage in fetch by locking once and using scoped MutexGuard (#34737)
Signed-off-by: Wulan Seruniati Salim <wulanseruniati@gmail.com>
This commit is contained in:
parent
b4bea0daf6
commit
2ab66ce678
1 changed files with 5 additions and 11 deletions
|
@ -101,17 +101,11 @@ pub type DoneChannel = Option<(TokioSender<Data>, TokioReceiver<Data>)>;
|
|||
pub async fn fetch(request: &mut Request, target: Target<'_>, context: &FetchContext) {
|
||||
// Steps 7,4 of https://w3c.github.io/resource-timing/#processing-model
|
||||
// rev order okay since spec says they're equal - https://w3c.github.io/resource-timing/#dfn-starttime
|
||||
context
|
||||
.timing
|
||||
.lock()
|
||||
.unwrap()
|
||||
.set_attribute(ResourceAttribute::FetchStart);
|
||||
context
|
||||
.timing
|
||||
.lock()
|
||||
.unwrap()
|
||||
.set_attribute(ResourceAttribute::StartTime(ResourceTimeValue::FetchStart));
|
||||
|
||||
{
|
||||
let mut timing_guard = context.timing.lock().unwrap();
|
||||
timing_guard.set_attribute(ResourceAttribute::FetchStart);
|
||||
timing_guard.set_attribute(ResourceAttribute::StartTime(ResourceTimeValue::FetchStart));
|
||||
}
|
||||
fetch_with_cors_cache(request, &mut CorsCache::default(), target, context).await;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue