Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Curler::Spooler() {
- Curl *c;
- std::vector<Curl *>::iterator ci;
- while (ready) {
- print_debug("Curler::Spooler - new loop");
- curl_mut.lock();
- while ((waiting_curls.size() > 0) && active_curls.size() < 10) { // We have capacity to process;
- ci = waiting_curls.begin();
- c = *ci;
- waiting_curls.erase(ci);
- active_curls.push_back(c);
- print_debug(string_format::str_printf("Curler::Spooler Activate waiting Jobid %d (FIFO)", c->JobId()));
- c->tw.run_detached(c);
- }
- print_debug("Curler::Spooler Cleanup the ready ones...");
- while (active_curls.size() > 0) {
- ci = active_curls.begin();
- c = *ci;
- if (c->Status() == Curl_Ready) { // This one finished
- print_debug(string_format::str_printf("Curler::Spooler Jobid %d finished", c->JobId()));
- active_curls.erase(ci);
- ready_curls.push_back(c);
- }
- }
- print_debug("Curler::Spooler Unlock...");
- curl_mut.unlock();
- print_debug("Curler::Spooler Go to sleep for 5 secs");
- mmsSleep(5);
- print_debug("Curler::Spooler continue");
- }
- print_debug("Curler::Spooler - We somehow lost control");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement