0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-29 08:13:46 +02:00

ircd:Ⓜ️:fetch: Deduplicate requests with shared futures.

This commit is contained in:
Jason Volk 2019-08-31 23:21:42 -07:00
parent 1210523757
commit cca4f223ff

View file

@ -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;
}