| 1440 | { |
| 1441 | |
| 1442 | void flushMulti(Coordination::ZooKeeper & zookeeper, Coordination::Requests & batch) |
| 1443 | { |
| 1444 | if (batch.empty()) |
| 1445 | return; |
| 1446 | |
| 1447 | auto promise = std::make_shared<std::promise<Coordination::MultiResponse>>(); |
| 1448 | auto future = promise->get_future(); |
| 1449 | zookeeper.multi(batch, [promise](const Coordination::MultiResponse & response) |
| 1450 | { |
| 1451 | promise->set_value(response); |
| 1452 | }); |
| 1453 | auto response = future.get(); |
| 1454 | if (response.error != Coordination::Error::ZOK) |
| 1455 | throw zkutil::KeeperException(response.error, "Multi request failed"); |
| 1456 | |
| 1457 | batch.clear(); |
| 1458 | } |
| 1459 | |
| 1460 | void addToBatchAndMaybeFlush(Coordination::ZooKeeper & zookeeper, Coordination::Requests & batch, Coordination::RequestPtr request) |
| 1461 | { |