mirror of
https://github.com/matrix-construct/construct
synced 2025-02-16 16:50:12 +01:00
ircd:Ⓜ️:fetch: Deduplicate requests with shared futures.
This commit is contained in:
parent
1210523757
commit
cca4f223ff
1 changed files with 10 additions and 6 deletions
|
@ -172,13 +172,15 @@ ircd::m::fetch::start(opts opts)
|
|||
requests.lower_bound(opts)
|
||||
};
|
||||
|
||||
if(it != end(requests) && !(*it < opts) && !(opts < *it))
|
||||
const bool exists
|
||||
{
|
||||
assert(it->opts.room_id == opts.room_id);
|
||||
return ctx::future<result>{}; //TODO: shared_future.
|
||||
}
|
||||
it != end(requests) && *it == opts
|
||||
};
|
||||
|
||||
assert(!exists || it->opts.room_id == opts.room_id);
|
||||
if(!exists)
|
||||
it = requests.emplace_hint(it, opts);
|
||||
|
||||
it = requests.emplace_hint(it, opts);
|
||||
auto &request
|
||||
{
|
||||
const_cast<fetch::request &>(*it)
|
||||
|
@ -189,7 +191,9 @@ ircd::m::fetch::start(opts opts)
|
|||
request.promise
|
||||
};
|
||||
|
||||
start(request);
|
||||
if(!exists)
|
||||
start(request);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue