本文整理汇总了C++中Promise::set_value方法的典型用法代码示例。如果您正苦于以下问题:C++ Promise::set_value方法的具体用法?C++ Promise::set_value怎么用?C++ Promise::set_value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Promise
的用法示例。
在下文中一共展示了Promise::set_value方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get
void get(const string &key, Promise<string> promise) {
auto it = buffer_.find(key);
if (it != buffer_.end()) {
return promise.set_value(it->second ? it->second.value() : "");
}
promise.set_value(kv_->get(key));
}
示例2: close
void close(Promise<> promise) {
do_flush(true /*force*/);
kv_safe_.reset();
kv_ = nullptr;
stop();
promise.set_value(Unit());
}
示例3: on_result
void on_result(uint64 id, BufferSlice packet) override {
auto result_ptr = fetch_result<telegram_api::messages_getBotCallbackAnswer>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
}
td->callback_queries_manager_->on_get_callback_query_answer(result_id_, result_ptr.move_as_ok());
promise_.set_value(Unit());
}
示例4: change_key
void change_key(DbKey db_key, Promise<> promise) {
binlog_->change_key(std::move(db_key));
promise.set_value(Unit());
}
示例5: close_and_destroy
void close_and_destroy(Promise<> promise) {
binlog_->close_and_destroy().ensure();
promise.set_value(Unit());
LOG(INFO) << "close_and_destroy: done";
stop();
}
示例6: get_stats
void FileStatsWorker::get_stats(bool need_all_files, bool split_by_owner_dialog_id, Promise<FileStats> promise) {
if (!G()->parameters().use_chat_info_db) {
split_by_owner_dialog_id = false;
}
if (!split_by_owner_dialog_id) {
FileStats file_stats;
file_stats.need_all_files = need_all_files;
auto start = Time::now();
scan_fs([&](FsFileInfo &fs_info) {
FullFileInfo info;
info.file_type = fs_info.file_type;
info.path = std::move(fs_info.path);
info.size = fs_info.size;
info.atime_nsec = fs_info.atime_nsec;
info.mtime_nsec = fs_info.mtime_nsec;
file_stats.add(std::move(info));
});
auto passed = Time::now() - start;
LOG_IF(INFO, passed > 0.5) << "Get file stats took: " << format::as_time(passed);
promise.set_value(std::move(file_stats));
} else {
auto start = Time::now();
std::vector<FullFileInfo> full_infos;
scan_fs([&](FsFileInfo &fs_info) {
FullFileInfo info;
info.file_type = fs_info.file_type;
info.path = std::move(fs_info.path);
info.size = fs_info.size;
info.atime_nsec = fs_info.atime_nsec;
info.mtime_nsec = fs_info.mtime_nsec;
// LOG(INFO) << "Found file of size " << info.size << " at " << info.path;
full_infos.push_back(std::move(info));
});
std::unordered_map<size_t, size_t> hash_to_pos;
size_t pos = 0;
for (auto &full_info : full_infos) {
hash_to_pos[std::hash<std::string>()(full_info.path)] = pos;
pos++;
}
scan_db([&](DbFileInfo &db_info) {
auto it = hash_to_pos.find(std::hash<std::string>()(db_info.path));
if (it == hash_to_pos.end()) {
return;
}
// LOG(INFO) << "Match! " << db_info.path << " from " << db_info.owner_dialog_id;
full_infos[it->second].owner_dialog_id = db_info.owner_dialog_id;
});
FileStats file_stats;
file_stats.need_all_files = need_all_files;
file_stats.split_by_owner_dialog_id = split_by_owner_dialog_id;
for (auto &full_info : full_infos) {
file_stats.add(std::move(full_info));
}
auto passed = Time::now() - start;
LOG_IF(INFO, passed > 0.5) << "Get file stats took: " << format::as_time(passed);
promise.set_value(std::move(file_stats));
}
}