remove ambigous Cluster ctor
[awesomized/libmemcached] / test / lib / Cluster.hpp
1 /*
2 +--------------------------------------------------------------------+
3 | libmemcached - C/C++ Client Library for memcached |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted under the terms of the BSD license. |
7 | You should have received a copy of the license in a bundled file |
8 | named LICENSE; in case you did not receive a copy you can review |
9 | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
10 +--------------------------------------------------------------------+
11 | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
12 | Copyright (c) 2020 Michael Wallner <mike@php.net> |
13 +--------------------------------------------------------------------+
14 */
15
16 #pragma once
17
18 #include "common.hpp"
19 #include "Server.hpp"
20
21 class Cluster {
22 public:
23 explicit Cluster(Server serv, uint16_t cnt = 3);
24 ~Cluster();
25
26 Cluster(const Cluster &c) = delete;
27 Cluster &operator=(const Cluster &c) = delete;
28
29 Cluster(Cluster &&c) noexcept
30 : proto{} {
31 *this = move(c);
32 };
33 Cluster &operator=(Cluster &&c) noexcept {
34 count = exchange(c.count, 0);
35 proto = exchange(c.proto, Server{});
36 cluster = exchange(c.cluster, {});
37 pids = exchange(c.pids, {});
38 return *this;
39 }
40
41 const vector<Server> &getServers() const;
42
43 bool start();
44 void stop(bool graceful = false);
45 bool isStopped();
46 bool isListening();
47 void wait();
48 bool restart();
49
50 private:
51 size_t count;
52 Server proto;
53 vector<Server> cluster;
54 map<pid_t, Server *> pids;
55
56 bool startServer(Server &server);
57 };