mirror of
https://github.com/matrix-construct/construct
synced 2024-11-26 08:42:34 +01:00
modules/client/sync/rooms/state: Hoist the event::fetch vector out of the concurrent closure.
This commit is contained in:
parent
3fe4baba4f
commit
9c3a0810cd
1 changed files with 15 additions and 6 deletions
|
@ -255,17 +255,24 @@ ircd::m::sync::room_state_polylog_events(data &data)
|
|||
*data.out, "events"
|
||||
};
|
||||
|
||||
sync::pool.min(64); //TODO: XXX
|
||||
static const auto num(64); //TODO: XXX
|
||||
sync::pool.min(num);
|
||||
|
||||
unsigned long long a_mask[2] {0};
|
||||
allocator::state a(num, a_mask);
|
||||
std::vector<m::event::fetch> events(num);
|
||||
ctx::concurrent<event::idx> concurrent
|
||||
{
|
||||
sync::pool, [&](const event::idx &event_idx)
|
||||
sync::pool, [&data, &ret, &mutex, &array, &events, &a](const auto &event_idx)
|
||||
{
|
||||
const m::event::fetch event
|
||||
const auto i(a.allocate(1)); const unwind i_{[&a, &i]
|
||||
{
|
||||
event_idx, std::nothrow
|
||||
};
|
||||
a.deallocate(i, 1);
|
||||
}};
|
||||
|
||||
if(unlikely(!event.valid))
|
||||
assert(i < events.size());
|
||||
auto &event(events.at(i));
|
||||
if(!m::seek(event, event_idx, std::nothrow))
|
||||
{
|
||||
log::error
|
||||
{
|
||||
|
@ -274,9 +281,11 @@ ircd::m::sync::room_state_polylog_events(data &data)
|
|||
string_view{data.room->room_id},
|
||||
};
|
||||
|
||||
assert(!event.valid);
|
||||
return;
|
||||
}
|
||||
|
||||
assert(event.valid);
|
||||
const std::lock_guard lock{mutex};
|
||||
ret |= room_state_append(data, array, event, event_idx);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue