Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
funclog.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#include "funclog.h"
3
4namespace Inkscape {
5namespace Util {
6
8{
9 for (auto h = first; h; destroy_and_advance(h)) {
10 try {
11 (*h)();
12 } catch (...) {
13 destroy_from(h);
14 reset();
15 std::rethrow_exception(std::current_exception());
16 }
17 }
18 reset();
19}
20
22{
23 auto next = h->next;
24 h->~Header();
25 h = next;
26}
27
28void FuncLog::reset() noexcept
29{
30 pool.free_all();
31 first = nullptr;
32 lastnext = &first;
33}
34
35void FuncLog::movefrom(FuncLog &other) noexcept
36{
37 pool = std::move(other.pool);
38 first = other.first;
39 lastnext = first ? other.lastnext : &first;
40
41 other.first = nullptr;
42 other.lastnext = &other.first;
43}
44
45} // namespace Util
46} // namespace Inkscape
A FuncLog is effectively a std::vector<std::function<void()>>, with the ability to hold move-only fun...
Definition funclog.h:24
void exec()
Execute and destroy each callable in the log.
Definition funclog.cpp:7
void movefrom(FuncLog &other) noexcept
Definition funclog.cpp:35
static void destroy_and_advance(Header *&h) noexcept
Definition funclog.cpp:21
static void destroy_from(Header *h)
Definition funclog.h:110
void reset() noexcept
Definition funclog.cpp:28
void free_all() noexcept
Free all previous allocations, retaining the largest existing buffer for re-use.
Definition pool.cpp:44
Miscellaneous supporting code.
Definition document.h:93
Helper class to stream background task notifications as a series of messages.