1.创建promise对象:
std::shared_ptr<std::promise<bool>> _discovery_promise = std::make_shared<std::promise<bool>>();
2.获取promise对象的future实例
auto future = _discovery_promise->get_future();//2.异步对象中获取future实例
3.设置promise对象中的共享内存值
_discovery_promise->set_value(true);//3.异步调用执行,设置操作标记
4.取future中的操作结果
//等待
bool wait() { return _discovery_future.get(); }//读取异步执行结果
完整示例:
#pragma once
#include <future>
#include <mutex>
#include <string>
#include "connection_re