X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=test%2Flib%2FCluster.hpp;h=ab20108c17d447a50532209c53a4b22fa2e75043;hb=6e8df95620d6c79a55d1f6996260303694026370;hp=1bbc9d22325568a7c64369b068b1e64175377c26;hpb=7e2b466107a65e22f1cc258ca8643922dbb60352;p=awesomized%2Flibmemcached diff --git a/test/lib/Cluster.hpp b/test/lib/Cluster.hpp index 1bbc9d22..ab20108c 100644 --- a/test/lib/Cluster.hpp +++ b/test/lib/Cluster.hpp @@ -1,3 +1,18 @@ +/* + +--------------------------------------------------------------------+ + | libmemcached - C/C++ Client Library for memcached | + +--------------------------------------------------------------------+ + | Redistribution and use in source and binary forms, with or without | + | modification, are permitted under the terms of the BSD license. | + | You should have received a copy of the license in a bundled file | + | named LICENSE; in case you did not receive a copy you can review | + | the terms online at: https://opensource.org/licenses/BSD-3-Clause | + +--------------------------------------------------------------------+ + | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ | + | Copyright (c) 2020 Michael Wallner | + +--------------------------------------------------------------------+ +*/ + #pragma once #include "common.hpp" @@ -5,20 +20,17 @@ class Cluster { public: - explicit - Cluster(Server serv, uint16_t cnt = 0); - + explicit Cluster(Server serv, size_t cnt = 3); ~Cluster(); Cluster(const Cluster &c) = delete; - Cluster &operator = (const Cluster &c) = delete; + Cluster &operator=(const Cluster &c) = delete; - Cluster(Cluster &&c) - : proto{} - { + Cluster(Cluster &&c) noexcept + : proto{} { *this = move(c); }; - Cluster &operator = (Cluster &&c) { + Cluster &operator=(Cluster &&c) noexcept { count = exchange(c.count, 0); proto = exchange(c.proto, Server{}); cluster = exchange(c.cluster, {}); @@ -29,17 +41,16 @@ public: const vector &getServers() const; bool start(); - void stop(); - void reset(); + void stop(bool graceful = false); bool isStopped(); - bool isListening(); + bool isListening() const; + bool ensureListening(); void wait(); + bool restart(); private: - uint16_t count; + size_t count; Server proto; vector cluster; map pids; - - bool startServer(Server &server); };