mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 23:14:13 +01:00
ircd::json::stack: Simplify checkpoint interface controls.
This commit is contained in:
parent
d3ca5d6490
commit
79a4394626
7 changed files with 29 additions and 35 deletions
|
@ -268,10 +268,9 @@ struct ircd::json::stack::checkpoint
|
|||
bool exception_rollback {true};
|
||||
|
||||
public:
|
||||
bool committing() const; ///< When false, destructor will rollback()
|
||||
bool recommit(); ///< Sets committing() to true.
|
||||
bool decommit(); ///< Sets committing() to false.
|
||||
bool rollback(); ///< Performs rollback of buffer.
|
||||
bool committing() const noexcept; ///< When false, destructor will rollback()
|
||||
bool committing(const bool &) noexcept; ///< Sets committing() to value.
|
||||
bool rollback(); ///< Performs rollback of buffer.
|
||||
|
||||
checkpoint(stack &s,
|
||||
const bool &committed = true,
|
||||
|
@ -351,3 +350,19 @@ ircd::json::stack::object::append(const json::tuple<T...> &t)
|
|||
};
|
||||
});
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::json::stack::checkpoint::committing(const bool &committed)
|
||||
noexcept
|
||||
{
|
||||
const bool ret(this->committed);
|
||||
this->committed = committed;
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::json::stack::checkpoint::committing()
|
||||
const noexcept
|
||||
{
|
||||
return committed;
|
||||
}
|
||||
|
|
25
ircd/json.cc
25
ircd/json.cc
|
@ -1731,7 +1731,7 @@ ircd::json::stack::checkpoint::~checkpoint()
|
|||
noexcept
|
||||
{
|
||||
if(std::uncaught_exceptions() && exception_rollback)
|
||||
decommit();
|
||||
committing(false);
|
||||
|
||||
if(!committing())
|
||||
rollback();
|
||||
|
@ -1772,31 +1772,10 @@ ircd::json::stack::checkpoint::rollback()
|
|||
else if(top.m)
|
||||
top.m->vc = vc;
|
||||
|
||||
recommit();
|
||||
committing(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::json::stack::checkpoint::decommit()
|
||||
{
|
||||
committed = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::json::stack::checkpoint::recommit()
|
||||
{
|
||||
committed = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::json::stack::checkpoint::committing()
|
||||
const
|
||||
{
|
||||
return committed;
|
||||
}
|
||||
|
||||
//
|
||||
// chase
|
||||
//
|
||||
|
|
|
@ -40,7 +40,7 @@ ircd::m::room::auth::generate(const mutable_buffer &buf,
|
|||
{
|
||||
json::stack::array array{out};
|
||||
if(!generate(array, room, event))
|
||||
cp.decommit();
|
||||
cp.committing(false);
|
||||
}
|
||||
|
||||
return json::array{out.completed()};
|
||||
|
|
|
@ -478,7 +478,7 @@ try
|
|||
ret = true;
|
||||
data.out->invalidate_checkpoints();
|
||||
}
|
||||
else checkpoint.decommit();
|
||||
else checkpoint.committing(false);
|
||||
|
||||
return true;
|
||||
});
|
||||
|
@ -518,7 +518,7 @@ try
|
|||
}
|
||||
|
||||
if(!ret)
|
||||
checkpoint.decommit();
|
||||
checkpoint.committing(false);
|
||||
|
||||
if(!data.phased && stats_info) log::info
|
||||
{
|
||||
|
@ -618,7 +618,7 @@ try
|
|||
|
||||
json::merge(top, vector);
|
||||
}
|
||||
else checkpoint.decommit();
|
||||
else checkpoint.committing(false);
|
||||
|
||||
log::debug
|
||||
{
|
||||
|
|
|
@ -262,13 +262,13 @@ ircd::m::sync::_rooms_polylog_room(data &data,
|
|||
ret = true;
|
||||
data.out->invalidate_checkpoints();
|
||||
}
|
||||
else checkpoint.decommit();
|
||||
else checkpoint.committing(false);
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
if(!ret)
|
||||
checkpoint.decommit();
|
||||
checkpoint.committing(false);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ get__make_join(client &client,
|
|||
};
|
||||
|
||||
if(!m::room::auth::generate(auth_events, room, m::event{args}))
|
||||
cp.decommit();
|
||||
cp.committing(false);
|
||||
}
|
||||
|
||||
json::stack::member
|
||||
|
|
|
@ -139,7 +139,7 @@ get__make_leave(client &client,
|
|||
};
|
||||
|
||||
if(!m::room::auth::generate(auth_events, room, m::event{args}))
|
||||
cp.decommit();
|
||||
cp.committing(false);
|
||||
}
|
||||
|
||||
json::stack::member
|
||||
|
|
Loading…
Reference in a new issue