MCPcopy Create free account
hub / github.com/FoundationDB/fdb-document-layer / prune

Method prune

src/Cursor.actor.cpp:26–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24#include "flow/actorcompiler.h" // This must be the last #include.
25
26int32_t Cursor::prune(std::map<int64_t, Reference<Cursor>>& cursors, bool pruneAll) {
27 time_t now = time(nullptr);
28 int32_t pruned = 0;
29 std::vector<Reference<Cursor>> to_be_pruned;
30
31 try {
32 for (auto it = cursors.begin(); it != cursors.end();) {
33 if (it->second && (pruneAll || now >= it->second->expiry)) {
34 to_be_pruned.push_back(it->second);
35 }
36 ++it;
37 }
38
39 for (const auto& i : to_be_pruned) {
40 (void)pluck(i);
41 pruned++;
42 }
43 } catch (Error& e) {
44 TraceEvent(SevError, "BD_cursor_prune_failed").error(e);
45 // Ignoring error just to keep the code consistent with previous behaviour.
46 // Cursor design could be made lot better than this.
47 }
48
49 return pruned;
50}
51
52void Cursor::pluck(Reference<Cursor> cursor) {
53 if (cursor) {

Callers

nothing calls this directly

Calls 2

beginMethod · 0.80
endMethod · 0.80

Tested by

no test coverage detected