danicoin/tests/IntegrationTestLib/NodeCallback.h
2016-01-18 15:33:29 +00:00

30 lines
725 B
C++

// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <future>
#include <INode.h>
namespace Tests {
class NodeCallback {
public:
CryptoNote::INode::Callback callback() {
prom = std::promise<std::error_code>(); // reset std::promise
result = prom.get_future();
return [this](std::error_code ec) {
std::promise<std::error_code> localPromise(std::move(prom));
localPromise.set_value(ec);
};
}
std::error_code get() {
return result.get();
}
private:
std::promise<std::error_code> prom;
std::future<std::error_code> result;
};
}