Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1.  
  2. void Curler::Spooler() {
  3. Curl *c;
  4. std::vector<Curl *>::iterator ci;
  5.  
  6. while (ready) {
  7. print_debug("Curler::Spooler - new loop");
  8. curl_mut.lock();
  9. while ((waiting_curls.size() > 0) && active_curls.size() < 10) { // We have capacity to process;
  10. ci = waiting_curls.begin();
  11. c = *ci;
  12. waiting_curls.erase(ci);
  13. active_curls.push_back(c);
  14. print_debug(string_format::str_printf("Curler::Spooler Activate waiting Jobid %d (FIFO)", c->JobId()));
  15. c->tw.run_detached(c);
  16. }
  17.  
  18. print_debug("Curler::Spooler Cleanup the ready ones...");
  19. while (active_curls.size() > 0) {
  20. ci = active_curls.begin();
  21. c = *ci;
  22. if (c->Status() == Curl_Ready) { // This one finished
  23. print_debug(string_format::str_printf("Curler::Spooler Jobid %d finished", c->JobId()));
  24. active_curls.erase(ci);
  25. ready_curls.push_back(c);
  26. }
  27. }
  28. print_debug("Curler::Spooler Unlock...");
  29. curl_mut.unlock();
  30. print_debug("Curler::Spooler Go to sleep for 5 secs");
  31. mmsSleep(5);
  32. print_debug("Curler::Spooler continue");
  33. }
  34. print_debug("Curler::Spooler - We somehow lost control");
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement