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; }
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); } } }