0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-27 11:18:51 +02:00

modules/vm: Replacements with scope_restore template.

This commit is contained in:
Jason Volk 2019-02-05 01:53:20 -08:00
parent ccf9f87e2a
commit 00c88ca073

View file

@ -137,13 +137,15 @@ ircd::m::vm::eval__commit_room(eval &eval,
// Set a member pointer to the json::iov currently being composed. This
// allows other parallel evals to have deep access to exactly what this
// eval is attempting to do.
eval.issue = &event;
eval.room_id = room.room_id;
const unwind deissue{[&eval]
const scope_restore<decltype(eval.issue)> eval_issue
{
eval.room_id = {};
eval.issue = nullptr;
}};
eval.issue, &event
};
const scope_restore<decltype(eval.room_id)> eval_room_id
{
eval.room_id, room.room_id
};
assert(eval.issue);
assert(eval.room_id);
@ -419,12 +421,12 @@ try
{
// Set a member pointer to the event currently being evaluated. This
// allows other parallel evals to have deep access to exactly what this
// eval is working on. The pointer must be nulled on the way out.
eval.event_ = &event;
const unwind null_event{[&eval]
// eval is working on.
assert(!eval.event_);
const scope_restore<decltype(eval.event_)> eval_event
{
eval.event_ = nullptr;
}};
eval.event_, &event
};
assert(eval.opts);
assert(eval.event_);
@ -673,11 +675,10 @@ ircd::m::vm::_write(eval &eval,
};
// Expose to eval interface
eval.txn = &txn;
const unwind clear{[&eval]
const scope_restore<decltype(eval.txn)> eval_txn
{
eval.txn = nullptr;
}};
eval.txn, &txn
};
// Preliminary write_opts
m::dbs::write_opts wopts;