Vuo  2.0.0
VuoModuleCompilationQueue.cc
Go to the documentation of this file.
1 
11 
16 {
17  sourceFile = nullptr;
18  loadingGroup = nullptr;
19 }
20 
25 {
26 }
27 
32 {
33  std::unique_lock<std::mutex> lock(queueMutex);
34 
35  queue[item->sourcePath].push_back({item, false});
36 }
37 
44 {
45  Item *item = nullptr;
46 
47  std::unique_lock<std::mutex> lock(queueMutex);
48  queueChanged.wait(lock, [this, &item](){
49 
50  for (auto &i : queue)
51  {
52  if (! i.second.front().second)
53  {
54  item = i.second.front().first;
55  i.second.front().second = true;
56  return true;
57  }
58  }
59 
60  return false;
61  });
62 
63  return item;
64 }
65 
70 {
71  std::unique_lock<std::mutex> lock(queueMutex);
72 
73  auto i = queue.find(item->sourcePath);
74 
75  delete i->second.front().first;
76  i->second.pop_front();
77 
78  if (i->second.empty())
79  queue.erase(i);
80 
81  queueChanged.notify_one();
82 }