本文整理汇总了C++中abort_callback::sleep方法的典型用法代码示例。如果您正苦于以下问题:C++ abort_callback::sleep方法的具体用法?C++ abort_callback::sleep怎么用?C++ abort_callback::sleep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类abort_callback
的用法示例。
在下文中一共展示了abort_callback::sleep方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
pfc::list_t<metadb_handle_ptr> get_sorted_playlist(const pfc::list_base_const_t<metadb_handle_ptr> &data, threaded_process_status &p_status, abort_callback &p_abort) {
std::multimap<int, metadb_handle_ptr, std::greater<int>> temp;
std::multimap<int, metadb_handle_ptr, std::greater<int>>::iterator it;
pfc::list_t<metadb_handle_ptr> result;
pfc::lores_timer timer;
pfc::string8 message, msg;
int size = data.get_count();
for (int i = 0; i < size; i++) {
message.reset();
message << "Track " << i + 1 << " of " << size;
p_status.set_item(message);
p_status.set_progress(i + 1, size);
timer.start();
const metadb_handle_ptr track = data[i];
int count = get_track_count(track, p_abort);
msg.reset();
msg << count;
console::print(msg);
// don't make more than 5 requests per second
// (averaged over a 5 minute period)
if (timer.query() < 0.2) {
p_abort.sleep(0.2);
}
if (i && (i % 100 == 0)) {
p_abort.sleep(10);
}
if (count > 0) {
temp.insert(std::pair<int, metadb_handle_ptr>(count, track));
} else {
temp.insert(std::pair<int, metadb_handle_ptr>(0, track));
}
}
for (it = temp.begin(); it != temp.end(); it++) {
metadb_handle_ptr track = it->second;
result.add_item(track);
}
return result;
}
示例2: g_open_for_info_write_timeout
void input_entry::g_open_for_info_write_timeout(service_ptr_t<input_info_writer> & p_instance,service_ptr_t<file> p_filehint,const char * p_path,abort_callback & p_abort,double p_timeout,bool p_from_redirect) {
pfc::lores_timer timer;
timer.start();
for(;;) {
try {
g_open_for_info_write(p_instance,p_filehint,p_path,p_abort,p_from_redirect);
break;
} catch(exception_io_sharing_violation) {
if (timer.query() > p_timeout) throw;
p_abort.sleep(0.01);
}
}
}