| 39 | using google::cloud::cpp_samples::UpdateObjectMetadata; |
| 40 | |
| 41 | class 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 | |
| 67 | void IndexGcsPrefix(pubsub::Message m, pubsub::AckHandler h, gcs::Client client, |
| 68 | pubsub::Publisher publisher, |
nothing calls this directly
no outgoing calls
no test coverage detected