class no_manage (clause modifier)
July 9, 2022 ยท View on GitHub
Specialisation for handlers that either:
-
Don't expose the resumption (i.e., all resumes happen within command clauses),
-
Don't access the handler object after resume,
which amounts to almost all practical use-cases of handlers. A
no_manage clause does not participate in the reference-counting
memory management of handlers, saving a tiny bit of performance.
template <typename Cmd>
struct no_manage { };
Usage:
struct MyCmd : command<int> { };
class MyHandler : flat_handler<bool, no_manage<MyCmd>> {
virtual bool handle_command(MyCmd, resumption<int> r) override
{
std::move(r).resume(3);
return 3;
}
}
The handle_commandfunction is the same as in a usual handler, but it is not memory-managed.
:information_source: plain and no_resume clauses are automatically no_manage.