MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/cpp-samples / MutationBatcher

Class MutationBatcher

getting-started/gke/index_gcs.cc:41–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39using google::cloud::cpp_samples::UpdateObjectMetadata;
40
41class MutationBatcher {
42 public:
43 MutationBatcher(spanner::Client client);
44
45 future<Status> Push(gcs::ObjectMetadata const& o);
46 // Return the number of mutations processed since the last Flush().
47 std::int64_t Flush();
48
49 void ReapBackgroundTasks();
50
51 private:
52 void FlushIfNeeded(std::unique_lock<std::mutex> const&);
53 void Flush(std::unique_lock<std::mutex> const&);
54
55 struct Item {
56 spanner::Mutation mutation;
57 promise<Status> done;
58 };
59
60 spanner::Client client_;
61 std::mutex mu_;
62 std::vector<Item> items_;
63 std::vector<std::future<void>> background_tasks_;
64 std::int64_t mutation_count_ = 0;
65};
66
67void IndexGcsPrefix(pubsub::Message m, pubsub::AckHandler h, gcs::Client client,
68 pubsub::Publisher publisher,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected