Audacity  3.0.3
ODManager.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity - A Digital Audio Editor
4  Copyright 1999-2010 Audacity Team
5  File License: wxWidgets
6 
7  Michael Chinen
8 
9 ******************************************************************//*******************************************************************/
16 
17 #include "../Audacity.h"
18 #include "ODManager.h"
19 
20 #include "ODTask.h"
21 #include "ODWaveTrackTaskQueue.h"
22 #include "../Project.h"
23 #include <wx/utils.h>
24 #include <wx/wx.h>
25 #include <wx/thread.h>
26 #include <wx/event.h>
27 
28 #ifdef __WXMAC__
29 
30 // On Mac OS X, it's better not to use the wxThread class.
31 // We use our own implementation based on pthreads instead.
32 
33 class ODTaskThread {
34  public:
35  typedef int ExitCode;
36  ODTaskThread(ODTask* task);
37  /*ExitCode*/ void Entry();
38  void Create() {}
39  void Delete() {
40  mDestroy = true;
41  pthread_join(mThread, NULL);
42  }
43  bool TestDestroy() { return mDestroy; }
44  void Sleep(int ms) {
45  struct timespec spec;
46  spec.tv_sec = 0;
47  spec.tv_nsec = ms * 1000 * 1000;
48  nanosleep(&spec, NULL);
49  }
50  static void *callback(void *p) {
51  ODTaskThread *th = (ODTaskThread *)p;
52 #if defined(__WXMAC__)
53  /*return (void *)*/ th->Entry();
54  return NULL;
55 #else
56  return (void *) th->Entry();
57 #endif
58  }
59  void Run() {
60  pthread_create(&mThread, NULL, callback, this);
61  }
62 
65  void SetPriority(int priority)
66  {
67  mPriority=priority;
68  }
69 
70  private:
71  int mPriority;
72  bool mDestroy;
73  pthread_t mThread;
74 
75  ODTask* mTask;
76 };
77 
78 #else
79 
80 class ODTaskThread final : public wxThread
81 {
82 public:
85  ODTaskThread(ODTask* task);
86 
87 
88 protected:
90  void* Entry() override;
92 
93 };
94 
95 #endif
96 
98 #ifndef __WXMAC__
99 : wxThread()
100 #endif
101 {
102  mTask=task;
103 #ifdef __WXMAC__
104  mDestroy = false;
105  mThread = NULL;
106 #endif
107 
108 }
109 
110 #ifdef __WXMAC__
111 
112 void ODTaskThread::Entry()
113 #else
115 
116 #endif
117 {
118  //TODO: Figure out why this has no effect at all.
119  //wxThread::This()->SetPriority( 40);
120  //Do at least 5 percent of the task
121  mTask->DoSome(0.05f);
122 
123  //release the thread count so that the ODManager knows how many active threads are alive.
125 
126 
127 #ifndef __WXMAC__
128  return NULL;
129 #endif
130 }
131 
133 static bool gManagerCreated=false;
134 static bool gPause=false; //to be loaded in and used with Pause/Resume before ODMan init.
136 static bool sHasLoadedOD=false;
137 
138 std::unique_ptr<ODManager> ODManager::pMan{};
139 //init the accessor function pointer - use the first time version of the interface fetcher
140 //first we need to typedef the function pointer type because the compiler doesn't support it in the raw
141 typedef ODManager* (*pfodman)();
143 
144 wxDEFINE_EVENT(EVT_ODTASK_UPDATE, wxCommandEvent);
145 
146 //using this with wxStringArray::Sort will give you a list that
147 //is alphabetical, without depending on case. If you use the
148 //default sort, you will get strings with 'R' before 'a', because it is in caps.
149 int CompareNoCaseFileName(const wxString& first, const wxString& second)
150 {
151  return first.CmpNoCase(second);
152 }
153 
154 //private constructor - Singleton.
156 {
157  mTerminate = false;
158  mTerminated = false;
159  mPause = gPause;
160 
161  //must set up the queue condition
162  mQueueNotEmptyCond = std::make_unique<ODCondition>(&mQueueNotEmptyCondLock);
163 }
164 
165 //private destructor - DELETE with static method Quit()
167 {
168  mTerminateMutex.Lock();
169  mTerminate = true;
170  mTerminateMutex.Unlock();
171 
172  //This while loop waits for ODTasks to finish and the DELETE removes all tasks from the Queue.
173  //This function is called from the main audacity event thread, so there should not be more requests for pMan
174  mTerminatedMutex.Lock();
175  while (!mTerminated)
176  {
177  mTerminatedMutex.Unlock();
178  wxThread::Sleep(200);
179 
180  //signal the queue not empty condition since the ODMan thread will wait on the queue condition
181  mQueueNotEmptyCondLock.Lock();
182  mQueueNotEmptyCond->Signal();
183  mQueueNotEmptyCondLock.Unlock();
184 
185  mTerminatedMutex.Lock();
186  }
187  mTerminatedMutex.Unlock();
188 
189  //get rid of all the queues. The queues get rid of the tasks, so we don't worry about them.
190  //nothing else should be running on OD related threads at this point, so we don't lock.
191  mQueues.clear();
192 }
193 
196 {
197  mTasksMutex.Lock();
198  mTasks.push_back(task);
199  mTasksMutex.Unlock();
200  //signal the queue not empty condition.
201  bool paused;
202 
203  mPauseLock.Lock();
204  paused=mPause;
205  mPauseLock.Unlock();
206 
207  //don't signal if we are paused since if we wake up the loop it will start processing other tasks while paused
208  if(!paused)
209  mQueueNotEmptyCond->Signal();
210 }
211 
213 {
214  bool paused;
215 
216  mPauseLock.Lock();
217  paused=mPause;
218  mPauseLock.Unlock();
219  //don't signal if we are paused
220  if(!paused)
221  mQueueNotEmptyCond->Signal();
222 }
223 
226 {
227  mTasksMutex.Lock();
228  //linear search okay for now, (probably only 1-5 tasks exist at a time.)
229  for(unsigned int i=0;i<mTasks.size();i++)
230  {
231  if(mTasks[i]==task)
232  {
233  mTasks.erase(mTasks.begin()+i);
234  break;
235  }
236  }
237  mTasksMutex.Unlock();
238 
239 }
240 
245 void ODManager::AddNewTask(std::unique_ptr<ODTask> &&mtask, bool lockMutex)
246 {
247  auto task = mtask.get();
248  ODWaveTrackTaskQueue* queue = NULL;
249 
250  if(lockMutex)
251  mQueuesMutex.Lock();
252  for(unsigned int i=0;i<mQueues.size();i++)
253  {
254  //search for a task containing the lead track. wavetrack removal is threadsafe and bound to the mQueuesMutex
255  //note that GetWaveTrack is not threadsafe, but we are assuming task is not running on a different thread yet.
256  if(mQueues[i]->ContainsWaveTrack(task->GetWaveTrack(0).get()))
257  queue = mQueues[i].get();
258  }
259 
260  if(queue)
261  {
262  //Add it to the existing queue but keep the lock since this reference can be deleted.
263  queue->AddTask(std::move(mtask));
264  if(lockMutex)
265  mQueuesMutex.Unlock();
266  }
267  else
268  {
269  //Make a NEW one, add it to the local track queue, and to the immediate running task list,
270  //since this task is definitely at the head
271  auto newqueue = std::make_unique<ODWaveTrackTaskQueue>();
272  newqueue->AddTask(std::move(mtask));
273  mQueues.push_back(std::move(newqueue));
274  if(lockMutex)
275  mQueuesMutex.Unlock();
276 
277  AddTask(task);
278  }
279 }
280 
281 //that switches out the mutex/null check.
283 {
284  gODInitedMutex.Lock();
285  if(!pMan)
286  {
287  pMan.reset(safenew ODManager());
288  pMan->Init();
289  gManagerCreated = true;
290  }
291  gODInitedMutex.Unlock();
292 
293  //change the accessor function to use the quicker method.
295 
296  return pMan.get();
297 }
298 
299 //faster method of instance fetching once init is done
301 {
302  return pMan.get();
303 }
304 
306 {
307  bool ret;
308  gODInitedMutex.Lock();
309  ret= gManagerCreated;
310  gODInitedMutex.Unlock();
311  return ret;
312 }
313 
316 {
317  mCurrentThreads = 0;
318  mMaxThreads = 5;
319 
320  // wxLogDebug(wxT("Initializing ODManager...Creating manager thread"));
321  // This is a detached thread, so it deletes itself when it finishes
322  // ... except on Mac where we don't use wxThread for reasons unexplained
324 
325 // startThread->SetPriority(0);//default of 50.
326  startThread->Create();
327 // wxPrintf("starting thread from init\n");
328  startThread->Run();
329 
330 // wxPrintf("started thread from init\n");
331  //destruction of thread is taken care of by thread library
332 }
333 
335 {
336  mCurrentThreadsMutex.Lock();
337  mCurrentThreads--;
338  mCurrentThreadsMutex.Unlock();
339 }
340 
343 {
344  bool tasksInArray;
345  bool paused;
346  int numQueues=0;
347 
348  mNeedsDraw=0;
349 
350  //wxLog calls not threadsafe. are printfs? thread-messy for sure, but safe?
351 // wxPrintf("ODManager thread strating \n");
352  //TODO: Figure out why this has no effect at all.
353  //wxThread::This()->SetPriority(30);
354  mTerminateMutex.Lock();
355  while(!mTerminate)
356  {
357  mTerminateMutex.Unlock();
358 // wxPrintf("ODManager thread running \n");
359 
360  //we should look at our WaveTrack queues to see if we can process a NEW task to the running queue.
361  UpdateQueues();
362 
363  //start some threads if necessary
364 
365  mTasksMutex.Lock();
366  tasksInArray = mTasks.size()>0;
367  mTasksMutex.Unlock();
368 
369  mPauseLock.Lock();
370  paused=mPause;
371  mPauseLock.Unlock();
372 
373  mCurrentThreadsMutex.Lock();
374  // keep adding tasks if there is work to do, up to the limit.
375  while(!paused && tasksInArray && (mCurrentThreads < mMaxThreads))
376  {
377  mCurrentThreads++;
378  mCurrentThreadsMutex.Unlock();
379 
380  mTasksMutex.Lock();
381  //detach a NEW thread.
382  // This is a detached thread, so it deletes itself when it finishes
383  // ... except on Mac where we don't use wxThread for reasons unexplained
384  auto thread = safenew ODTaskThread(mTasks[0]);//task);
385  //thread->SetPriority(10);//default is 50.
386  thread->Create();
387  thread->Run();
388 
389  mTasks.erase(mTasks.begin());
390  tasksInArray = mTasks.size()>0;
391  mTasksMutex.Unlock();
392 
393  mCurrentThreadsMutex.Lock();
394  }
395 
396  mCurrentThreadsMutex.Unlock();
397  //use a condition variable to block here instead of a sleep.
398 
399  // JKC: If there are no tasks ready to run, or we're paused then
400  // we wait for there to be tasks in the queue.
401  {
402  ODLocker locker{ &mQueueNotEmptyCondLock };
403  if( (!tasksInArray) || paused)
404  mQueueNotEmptyCond->Wait();
405  }
406 
407  //if there is some ODTask running, then there will be something in the queue. If so then redraw to show progress
408  mQueuesMutex.Lock();
409  mNeedsDraw += mQueues.size()>0?1:0;
410  numQueues=mQueues.size();
411  mQueuesMutex.Unlock();
412 
413  //redraw the current project only (ODTasks will send a redraw on complete even if the projects are in the background)
414  //we don't want to redraw at a faster rate when we have more queues because
415  //this means the CPU is already taxed. This if statement normalizes the rate
416  if((mNeedsDraw>numQueues) && numQueues)
417  {
418  mNeedsDraw=0;
419  wxCommandEvent event( EVT_ODTASK_UPDATE );
420  wxTheApp->AddPendingEvent(event);
421  }
422  mTerminateMutex.Lock();
423  }
424  mTerminateMutex.Unlock();
425 
426  mTerminatedMutex.Lock();
427  mTerminated=true;
428  mTerminatedMutex.Unlock();
429 
430  //wxLogDebug Not thread safe.
431  //wxPrintf("ODManager thread terminating\n");
432 }
433 
434 //static function that prevents ODTasks from being scheduled
435 //does not stop currently running tasks from completing their immediate subtask,
436 //but presumably they will finish within a second
437 void ODManager::Pauser::Pause(bool pause)
438 {
439  if(IsInstanceCreated())
440  {
441  pMan->mPauseLock.Lock();
442  pMan->mPause = pause;
443  pMan->mPauseLock.Unlock();
444 
445  if(!pause)
446  //we should check the queue again.
447  pMan->mQueueNotEmptyCond->Signal();
448  }
449  else
450  {
451  gPause=pause;
452  }
453 }
454 
456 {
457  Pause(false);
458 }
459 
461 {
462  if(IsInstanceCreated())
463  {
464  pMan.reset();
465  }
466 }
467 
470  const std::shared_ptr<Track> &newTrack)
471 {
472  mQueuesMutex.Lock();
473  for(unsigned int i=0;i<mQueues.size();i++)
474  {
475  mQueues[i]->ReplaceWaveTrack( oldTrack, newTrack );
476  }
477  mQueuesMutex.Unlock();
478 }
479 
482  const std::shared_ptr< WaveTrack > &track)
483 {
484  ODWaveTrackTaskQueue* owner=NULL;
485  mQueuesMutex.Lock();
486  for(unsigned int i=0;i<mQueues.size();i++)
487  {
488  if(mQueues[i]->ContainsWaveTrack(track.get()))
489  {
490  owner = mQueues[i].get();
491  break;
492  }
493  }
494  if(owner)
495  owner->MakeWaveTrackIndependent(track);
496 
497  mQueuesMutex.Unlock();
498 }
499 
506  const std::shared_ptr< WaveTrack > &dependentTrack,
507  WaveTrack* masterTrack
508 )
509 {
510  //First, check to see if the task lists are mergeable. If so, we can simply add this track to the other task and queue,
511  //then DELETE this one.
512  ODWaveTrackTaskQueue* masterQueue=NULL;
513  ODWaveTrackTaskQueue* dependentQueue=NULL;
514  unsigned int dependentIndex = 0;
515  bool canMerge = false;
516 
517  mQueuesMutex.Lock();
518  for(unsigned int i=0;i<mQueues.size();i++)
519  {
520  if(mQueues[i]->ContainsWaveTrack(masterTrack))
521  {
522  masterQueue = mQueues[i].get();
523  }
524  else if(mQueues[i]->ContainsWaveTrack(dependentTrack.get()))
525  {
526  dependentQueue = mQueues[i].get();
527  dependentIndex = i;
528  }
529 
530  }
531  if(masterQueue&&dependentQueue)
532  canMerge=masterQueue->CanMergeWith(dependentQueue);
533 
534  //otherwise we need to let dependentTrack's queue live on. We'll have to wait till the conflicting tasks are done.
535  if(!canMerge)
536  {
537  mQueuesMutex.Unlock();
538  return false;
539  }
540  //then we add dependentTrack to the masterTrack's queue - this will allow future ODScheduling to affect them together.
541  //this sets the NeedODUpdateFlag since we don't want the head task to finish without haven't dealt with the dependent
542  masterQueue->MergeWaveTrack(dependentTrack);
543 
544  //finally remove the dependent track
545  mQueues.erase(mQueues.begin()+dependentIndex);
546  mQueuesMutex.Unlock();
547  return true;
548 }
549 
550 
554 void ODManager::DemandTrackUpdate(WaveTrack* track, double seconds)
555 {
556  mQueuesMutex.Lock();
557  for(unsigned int i=0;i<mQueues.size();i++)
558  {
559  mQueues[i]->DemandTrackUpdate(track,seconds);
560  }
561  mQueuesMutex.Unlock();
562 }
563 
567 {
568  mQueuesMutex.Lock();
569  for(unsigned int i=0;i<mQueues.size();i++)
570  {
571  if(mQueues[i]->IsFrontTaskComplete())
572  {
573  //this should DELETE and remove the front task instance.
574  mQueues[i]->RemoveFrontTask();
575  //schedule next.
576  if(!mQueues[i]->IsEmpty())
577  {
578  //we need to release the lock on the queue vector before using the task vector's lock or we deadlock
579  //so get a temp.
580  ODWaveTrackTaskQueue* queue = mQueues[i].get();
581 
582  AddTask(queue->GetFrontTask());
583  }
584  }
585 
586  //if the queue is empty DELETE it.
587  if(mQueues[i]->IsEmpty())
588  {
589  mQueues.erase(mQueues.begin()+i);
590  i--;
591  }
592  }
593  mQueuesMutex.Unlock();
594 }
595 
596 //static
599 {
600  sHasLoadedOD = true;
601 }
602 
603 //static
606 {
607  sHasLoadedOD = false;
608 }
609 
610 //static
613 {
614  return sHasLoadedOD;
615 }
616 
619 {
620  mQueuesMutex.Lock();
621  for(unsigned int i=0;i<mQueues.size();i++)
622  {
623  mQueues[i]->FillTipForWaveTrack(t, tip);
624  }
625  mQueuesMutex.Unlock();
626 }
627 
630 {
631  float total=0.0;
632  mQueuesMutex.Lock();
633  for(unsigned int i=0;i<mQueues.size();i++)
634  {
635  total+=mQueues[i]->GetFrontTask()->PercentComplete();
636  }
637  mQueuesMutex.Unlock();
638 
639  //avoid div by zero and be thread smart.
640  int totalTasks = GetTotalNumTasks();
641  return (float) total/(totalTasks>0?totalTasks:1);
642 }
643 
646 {
647  int ret=0;
648  mQueuesMutex.Lock();
649  for(unsigned int i=0;i<mQueues.size();i++)
650  {
651  ret+=mQueues[i]->GetNumTasks();
652  }
653  mQueuesMutex.Unlock();
654  return ret;
655 }
ODManager::ODManager
ODManager()
Definition: ODManager.cpp:155
ODManager::GetOverallPercentComplete
float GetOverallPercentComplete()
Gets the total percent complete for all tasks combined.
Definition: ODManager.cpp:629
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
pfodman
ODManager *(* pfodman)()
Definition: ODManager.cpp:141
ODManager::mCurrentThreads
volatile int mCurrentThreads
Number of threads currently running. Accessed thru multiple threads.
Definition: ODManager.h:162
ODManager::mCurrentThreadsMutex
ODLock mCurrentThreadsMutex
Definition: ODManager.h:164
ODManager::mTerminated
volatile bool mTerminated
Definition: ODManager.h:172
wxDEFINE_EVENT
wxDEFINE_EVENT(EVT_ODTASK_UPDATE, wxCommandEvent)
ODManager::mTerminatedMutex
ODLock mTerminatedMutex
Definition: ODManager.h:173
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
ODManager::mNeedsDraw
volatile int mNeedsDraw
Definition: ODManager.h:159
ODManager::mQueues
std::vector< std::unique_ptr< ODWaveTrackTaskQueue > > mQueues
Definition: ODManager.h:147
ODWaveTrackTaskQueue::GetFrontTask
ODTask * GetFrontTask()
Schedules the front task for immediate execution.
Definition: ODWaveTrackTaskQueue.cpp:294
ODManager::MakeWaveTrackIndependent
void MakeWaveTrackIndependent(const std::shared_ptr< WaveTrack > &track)
if it shares a queue/task, creates a NEW queue/task for the track, and removes it from any previously...
Definition: ODManager.cpp:481
gPause
static bool gPause
Definition: ODManager.cpp:134
ODManager::Pauser::Resume
static void Resume()
Definition: ODManager.cpp:455
ODManager::MakeWaveTrackDependent
bool MakeWaveTrackDependent(const std::shared_ptr< WaveTrack > &dependentTrack, WaveTrack *masterTrack)
Definition: ODManager.cpp:505
ODManager::ODManagerHelperThread
Definition: ODManager.h:227
ODTaskThread
A thread that executes a part of the task specified by an ODTask.
Definition: ODManager.cpp:81
ODWaveTrackTaskQueue::AddTask
void AddTask(std::unique_ptr< ODTask > &&mtask)
Add a task to the queue.
Definition: ODWaveTrackTaskQueue.cpp:108
ODManager::Pauser::Pause
static void Pause(bool pause=true)
Definition: ODManager.cpp:437
audacity::network_manager::RequestVerb::Delete
@ Delete
ODManager::AddNewTask
void AddNewTask(std::unique_ptr< ODTask > &&mtask, bool lockMutex=true)
Adds a wavetrack, creates a queue member.
Definition: ODManager.cpp:245
ODTaskThread::mTask
ODTask * mTask
Definition: ODManager.cpp:91
ODManager::InstanceNormal
static ODManager * InstanceNormal()
Gets the singleton instance.
Definition: ODManager.cpp:300
ODManager::IsInstanceCreated
static bool IsInstanceCreated()
returns whether or not the singleton instance was created yet
Definition: ODManager.cpp:305
gManagerCreated
static bool gManagerCreated
Definition: ODManager.cpp:133
ODManager::InstanceFirstTime
static ODManager * InstanceFirstTime()
Gets the singleton instance.
Definition: ODManager.cpp:282
ODManager::DemandTrackUpdate
void DemandTrackUpdate(WaveTrack *track, double seconds)
changes the tasks associated with this Waveform to process the task from a different point in the tra...
Definition: ODManager.cpp:554
ODManager::AddTask
void AddTask(ODTask *task)
Adds a task to the running queue. Thread-safe.
Definition: ODManager.cpp:195
ODManager::SignalTaskQueueLoop
void SignalTaskQueueLoop()
Wakes the queue loop up by signalling its condition variable.
Definition: ODManager.cpp:212
ODManager::Quit
static void Quit()
Kills the ODMananger Thread.
Definition: ODManager.cpp:460
ODManager::FillTipForWaveTrack
void FillTipForWaveTrack(const WaveTrack *t, TranslatableString &tip)
fills in the status bar message for a given track
Definition: ODManager.cpp:618
ODManager.h
ODManager::MarkLoadedODFlag
static void MarkLoadedODFlag()
sets a flag that is set if we have loaded some OD blockfiles from PCM.
Definition: ODManager.cpp:598
ODManager::mTerminateMutex
ODLock mTerminateMutex
Definition: ODManager.h:170
ODTaskThread::Entry
void * Entry() override
Executes a part of the task.
Definition: ODManager.cpp:114
sHasLoadedOD
static bool sHasLoadedOD
a flag that is set if we have loaded some OD blockfiles from PCM.
Definition: ODManager.cpp:136
ODManager::RemoveTaskIfInQueue
void RemoveTaskIfInQueue(ODTask *task)
removes a task from the active task queue
Definition: ODManager.cpp:225
ODManager::mQueueNotEmptyCondLock
ODLock mQueueNotEmptyCondLock
Definition: ODManager.h:176
ODWaveTrackTaskQueue.h
ODWaveTrackTaskQueue::MakeWaveTrackIndependent
void MakeWaveTrackIndependent(const std::shared_ptr< WaveTrack > &track)
Definition: ODWaveTrackTaskQueue.cpp:131
ODManager::mTasksMutex
ODLock mTasksMutex
Definition: ODManager.h:153
ODManager::UnmarkLoadedODFlag
static void UnmarkLoadedODFlag()
resets a flag that is set if we have loaded some OD blockfiles from PCM.
Definition: ODManager.cpp:605
ODManager::mTasks
std::vector< ODTask * > mTasks
Definition: ODManager.h:151
ODManager::mPauseLock
ODLock mPauseLock
Definition: ODManager.h:157
ODManager::mQueuesMutex
ODLock mQueuesMutex
Definition: ODManager.h:148
ODManager::GetTotalNumTasks
int GetTotalNumTasks()
Get Total Number of Tasks.
Definition: ODManager.cpp:645
ODWaveTrackTaskQueue::CanMergeWith
bool CanMergeWith(ODWaveTrackTaskQueue *otherQueue)
returns whether or not this queue's task list and another's can merge together, as when we make two m...
Definition: ODWaveTrackTaskQueue.cpp:44
ODLocker
Definition: ODTaskThread.h:120
ODManager::mQueueNotEmptyCond
std::unique_ptr< ODCondition > mQueueNotEmptyCond
Definition: ODManager.h:177
ODManager::pMan
static std::unique_ptr< ODManager > pMan
Definition: ODManager.h:144
ODWaveTrackTaskQueue
A class representing a modular task to be used with the On-Demand structures.
Definition: ODWaveTrackTaskQueue.h:33
ODTask
A class representing a modular task to be used with the On-Demand structures.
Definition: ODTask.h:40
ODManager::mTerminate
volatile bool mTerminate
Definition: ODManager.h:169
ODManager::Start
void Start()
Start the main loop for the manager.
Definition: ODManager.cpp:342
ODWaveTrackTaskQueue::MergeWaveTrack
void MergeWaveTrack(const std::shared_ptr< WaveTrack > &track)
Definition: ODWaveTrackTaskQueue.cpp:67
ODTask.h
gODInitedMutex
static ODLock gODInitedMutex
Definition: ODManager.cpp:132
ODLock
Definition: ODTaskThread.h:89
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:239
ODTaskThread::ODTaskThread
ODTaskThread(ODTask *task)
Definition: ODManager.cpp:97
ODManager::Init
void Init()
Launches a thread for the manager and starts accepting Tasks.
Definition: ODManager.cpp:315
CompareNoCaseFileName
int CompareNoCaseFileName(const wxString &first, const wxString &second)
wxstring compare function for sorting case, which is needed to load correctly.
Definition: ODManager.cpp:149
ODManager::mPause
volatile bool mPause
Definition: ODManager.h:156
ODManager::HasLoadedODFlag
static bool HasLoadedODFlag()
returns a flag that is set if we have loaded some OD blockfiles from PCM.
Definition: ODManager.cpp:612
ODManager::DecrementCurrentThreads
void DecrementCurrentThreads()
Reduces the count of current threads running. Meant to be called when ODTaskThreads end in their own ...
Definition: ODManager.cpp:334
ODTask::GetWaveTrack
virtual std::shared_ptr< WaveTrack > GetWaveTrack(int i)
Definition: ODTask.cpp:255
ODManager::~ODManager
~ODManager()
Definition: ODManager.cpp:166
ODManager::Instance
static ODManager *(* Instance)()
Definition: ODManager.h:51
safenew
#define safenew
Definition: MemoryX.h:10
ODManager::ReplaceWaveTrack
void ReplaceWaveTrack(Track *oldTrack, const std::shared_ptr< Track > &newTrack)
replace the wavetrack whose wavecache the gui watches for updates
Definition: ODManager.cpp:469
ODManager
A singleton that manages currently running Tasks on an arbitrary number of threads.
Definition: ODManager.h:46
ODManager::mMaxThreads
int mMaxThreads
Maximum number of threads allowed out.
Definition: ODManager.h:167
ODManager::UpdateQueues
void UpdateQueues()
Remove references in our array to Tasks that have been completed/Schedule NEW ones.
Definition: ODManager.cpp:566