Advertisement
zamotivator

Untitled

May 30th, 2015
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. threads::Worker apiWorker(const ConfigHolder& config, MySQL& mysql,
  2.                           ExportQueue& in, WriteQueue& out)
  3. {
  4.     auto consumer = [&config, &out](const GroupId& groupId)
  5.     {
  6.         auto progress = [&mysql, groupId](uint32_t current, uint32_t total)
  7.         {
  8.             mysql.updateCount(groupId, current, total);
  9.         };
  10.         auto groupInfo = apiFetch(config, groupId, progress);
  11.         out.push(groupInfo);
  12.     };
  13.     auto failure = [&mysql](const GroupId& groupId, std::exception& error)
  14.     {
  15.         logger.rb::streamError("%s", error.what());
  16.         mysql.updateStatus(groupId, GroupStatus::API_EXPORTING);
  17.     };
  18.     return threads::queueConsumer(in, 100, consumer, failure);
  19. }
  20.  
  21.  
  22. threads::Supervisor apiSupervisor(const ConfigHolder& config, MySQL& mysql,
  23.                         ExportQueue& in, WriteQueue& out)
  24. {
  25.     auto workerCreate = [&]()
  26.     {
  27.         return apiWorker(config, mysql, in, out);
  28.     };
  29.     threads::Supervisor sResult(workerCreate);
  30.     sResult.resize(config.get()->api.worker_count);
  31.     return sResult;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement