Audacity
3.0.3
|
A singleton that manages currently running Tasks on an arbitrary number of threads. More...
#include <ODManager.h>
Classes | |
class | ODManagerHelperThread |
class | Pauser |
Public Member Functions | |
void | DemandTrackUpdate (WaveTrack *track, double seconds) |
changes the tasks associated with this Waveform to process the task from a different point in the track More... | |
void | DecrementCurrentThreads () |
Reduces the count of current threads running. Meant to be called when ODTaskThreads end in their own threads. Thread-safe. More... | |
void | AddNewTask (std::unique_ptr< ODTask > &&mtask, bool lockMutex=true) |
Adds a wavetrack, creates a queue member. More... | |
void | SignalTaskQueueLoop () |
Wakes the queue loop up by signalling its condition variable. More... | |
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 existing tasks. More... | |
bool | MakeWaveTrackDependent (const std::shared_ptr< WaveTrack > &dependentTrack, WaveTrack *masterTrack) |
void | ReplaceWaveTrack (Track *oldTrack, const std::shared_ptr< Track > &newTrack) |
replace the wavetrack whose wavecache the gui watches for updates More... | |
void | AddTask (ODTask *task) |
Adds a task to the running queue. Thread-safe. More... | |
void | RemoveTaskIfInQueue (ODTask *task) |
removes a task from the active task queue More... | |
void | FillTipForWaveTrack (const WaveTrack *t, TranslatableString &tip) |
fills in the status bar message for a given track More... | |
float | GetOverallPercentComplete () |
Gets the total percent complete for all tasks combined. More... | |
int | GetTotalNumTasks () |
Get Total Number of Tasks. More... | |
Static Public Member Functions | |
static ODManager * | InstanceFirstTime () |
Gets the singleton instance. More... | |
static ODManager * | InstanceNormal () |
Gets the singleton instance. More... | |
static void | Quit () |
Kills the ODMananger Thread. More... | |
static void | MarkLoadedODFlag () |
sets a flag that is set if we have loaded some OD blockfiles from PCM. More... | |
static void | UnmarkLoadedODFlag () |
resets a flag that is set if we have loaded some OD blockfiles from PCM. More... | |
static bool | HasLoadedODFlag () |
returns a flag that is set if we have loaded some OD blockfiles from PCM. More... | |
static bool | IsInstanceCreated () |
returns whether or not the singleton instance was created yet More... | |
Static Public Attributes | |
static ODManager *(* | Instance )() = &(ODManager::InstanceFirstTime) |
Protected Member Functions | |
ODManager () | |
~ODManager () | |
void | Init () |
Launches a thread for the manager and starts accepting Tasks. More... | |
void | Start () |
Start the main loop for the manager. More... | |
void | UpdateQueues () |
Remove references in our array to Tasks that have been completed/Schedule NEW ones. More... | |
Protected Attributes | |
std::vector< std::unique_ptr< ODWaveTrackTaskQueue > > | mQueues |
ODLock | mQueuesMutex |
std::vector< ODTask * > | mTasks |
ODLock | mTasksMutex |
volatile bool | mPause |
ODLock | mPauseLock |
volatile int | mNeedsDraw |
volatile int | mCurrentThreads |
Number of threads currently running. Accessed thru multiple threads. More... | |
ODLock | mCurrentThreadsMutex |
int | mMaxThreads |
Maximum number of threads allowed out. More... | |
volatile bool | mTerminate |
ODLock | mTerminateMutex |
volatile bool | mTerminated |
ODLock | mTerminatedMutex |
ODLock | mQueueNotEmptyCondLock |
std::unique_ptr< ODCondition > | mQueueNotEmptyCond |
Static Protected Attributes | |
static std::unique_ptr< ODManager > | pMan {} |
A singleton that manages currently running Tasks on an arbitrary number of threads.
Definition at line 45 of file ODManager.h.
|
protected |
Definition at line 155 of file ODManager.cpp.
References gPause, mPause, mQueueNotEmptyCond, mQueueNotEmptyCondLock, mTerminate, and mTerminated.
Referenced by InstanceFirstTime().
|
protected |
Definition at line 166 of file ODManager.cpp.
References mQueueNotEmptyCond, mQueueNotEmptyCondLock, mQueues, mTerminate, mTerminated, mTerminatedMutex, and mTerminateMutex.
void ODManager::AddNewTask | ( | std::unique_ptr< ODTask > && | mtask, |
bool | lockMutex = true |
||
) |
Adds a wavetrack, creates a queue member.
Adds a NEW task to the queue. Creates a queue if the tracks associated with the task is not in the list
task | the task to add |
lockMutex | locks the mutexes if true (default). This function is used within other ODManager calls, which many need to set this to false. |
Definition at line 245 of file ODManager.cpp.
References AddTask(), ODWaveTrackTaskQueue::AddTask(), ODTask::GetWaveTrack(), mQueues, and mQueuesMutex.
Referenced by ODWaveTrackTaskQueue::MakeWaveTrackIndependent().
void ODManager::AddTask | ( | ODTask * | task | ) |
Adds a task to the running queue. Thread-safe.
Adds a task to running queue. Thread-safe.
Definition at line 195 of file ODManager.cpp.
References mPause, mPauseLock, mQueueNotEmptyCond, mTasks, and mTasksMutex.
Referenced by AddNewTask(), ODTask::DoSome(), and UpdateQueues().
void ODManager::DecrementCurrentThreads | ( | ) |
Reduces the count of current threads running. Meant to be called when ODTaskThreads end in their own threads. Thread-safe.
Definition at line 334 of file ODManager.cpp.
References mCurrentThreads, and mCurrentThreadsMutex.
Referenced by ODTaskThread::Entry().
void ODManager::DemandTrackUpdate | ( | WaveTrack * | track, |
double | seconds | ||
) |
changes the tasks associated with this Waveform to process the task from a different point in the track
changes the tasks associated with this Waveform to process the task from a different point in the track
track | the track to update |
seconds | the point in the track from which the tasks associated with track should begin processing from. |
Definition at line 554 of file ODManager.cpp.
References mQueues, and mQueuesMutex.
void ODManager::FillTipForWaveTrack | ( | const WaveTrack * | t, |
TranslatableString & | tip | ||
) |
fills in the status bar message for a given track
Definition at line 618 of file ODManager.cpp.
References mQueues, and mQueuesMutex.
float ODManager::GetOverallPercentComplete | ( | ) |
Gets the total percent complete for all tasks combined.
Definition at line 629 of file ODManager.cpp.
References GetTotalNumTasks(), mQueues, and mQueuesMutex.
int ODManager::GetTotalNumTasks | ( | ) |
Get Total Number of Tasks.
Definition at line 645 of file ODManager.cpp.
References mQueues, and mQueuesMutex.
Referenced by GetOverallPercentComplete().
|
static |
returns a flag that is set if we have loaded some OD blockfiles from PCM.
Definition at line 612 of file ODManager.cpp.
References sHasLoadedOD.
|
protected |
Launches a thread for the manager and starts accepting Tasks.
Definition at line 315 of file ODManager.cpp.
References mCurrentThreads, mMaxThreads, and safenew.
|
static |
Gets the singleton instance.
Definition at line 282 of file ODManager.cpp.
References gManagerCreated, gODInitedMutex, Instance, InstanceNormal(), ODManager(), pMan, and safenew.
|
static |
Gets the singleton instance.
Definition at line 300 of file ODManager.cpp.
References pMan.
Referenced by InstanceFirstTime().
|
static |
returns whether or not the singleton instance was created yet
Definition at line 305 of file ODManager.cpp.
References gManagerCreated, and gODInitedMutex.
Referenced by ODManager::Pauser::Pause(), and Quit().
bool ODManager::MakeWaveTrackDependent | ( | const std::shared_ptr< WaveTrack > & | dependentTrack, |
WaveTrack * | masterTrack | ||
) |
attach the track in question to another, already existing track's queues and tasks. Remove the task/tracks. Returns success if it was possible.. Some ODTask conditions make it impossible until the Tasks finish.
attach the track in question to another, already existing track's queues and tasks. Remove the task/tracks. only works if both tracks exist. Sets needODUpdate flag for the task. This is complicated and will probably need better design in the future.
Definition at line 505 of file ODManager.cpp.
References ODWaveTrackTaskQueue::CanMergeWith(), ODWaveTrackTaskQueue::MergeWaveTrack(), mQueues, and mQueuesMutex.
void ODManager::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 existing tasks.
Definition at line 481 of file ODManager.cpp.
References ODWaveTrackTaskQueue::MakeWaveTrackIndependent(), mQueues, and mQueuesMutex.
|
static |
sets a flag that is set if we have loaded some OD blockfiles from PCM.
Definition at line 598 of file ODManager.cpp.
References sHasLoadedOD.
|
static |
Kills the ODMananger Thread.
Definition at line 460 of file ODManager.cpp.
References IsInstanceCreated(), and pMan.
void ODManager::RemoveTaskIfInQueue | ( | ODTask * | task | ) |
removes a task from the active task queue
Definition at line 225 of file ODManager.cpp.
References mTasks, and mTasksMutex.
Referenced by ODWaveTrackTaskQueue::~ODWaveTrackTaskQueue().
replace the wavetrack whose wavecache the gui watches for updates
if oldTrack is being watched, replace the wavetrack whose wavecache the gui watches for updates
Definition at line 469 of file ODManager.cpp.
References mQueues, and mQueuesMutex.
void ODManager::SignalTaskQueueLoop | ( | ) |
Wakes the queue loop up by signalling its condition variable.
Definition at line 212 of file ODManager.cpp.
References mPause, mPauseLock, and mQueueNotEmptyCond.
|
protected |
Start the main loop for the manager.
Main loop for managing threads and tasks.
Definition at line 342 of file ODManager.cpp.
References mCurrentThreads, mCurrentThreadsMutex, mMaxThreads, mNeedsDraw, mPause, mPauseLock, mQueueNotEmptyCond, mQueueNotEmptyCondLock, mQueues, mQueuesMutex, mTasks, mTasksMutex, mTerminate, mTerminated, mTerminatedMutex, mTerminateMutex, safenew, and UpdateQueues().
Referenced by ODManager::ODManagerHelperThread::Entry().
|
static |
resets a flag that is set if we have loaded some OD blockfiles from PCM.
Definition at line 605 of file ODManager.cpp.
References sHasLoadedOD.
|
protected |
Remove references in our array to Tasks that have been completed/Schedule NEW ones.
remove tasks from ODWaveTrackTaskQueues that have been done. Schedules NEW ones if they exist Also remove queues that have become empty.
Definition at line 566 of file ODManager.cpp.
References AddTask(), ODWaveTrackTaskQueue::GetFrontTask(), mQueues, and mQueuesMutex.
Referenced by Start().
|
static |
Gets the singleton instance - this is a function pointer that points to one of the below two instance calls. Note that it is not a member function pointer since it is a static function. the function pointer swapping is valid as long as the initial calls only happen from the main thread.
Definition at line 51 of file ODManager.h.
Referenced by ODTask::DoSome(), ODManager::ODManagerHelperThread::Entry(), ODTaskThread::Entry(), InstanceFirstTime(), ODWaveTrackTaskQueue::MakeWaveTrackIndependent(), and ODWaveTrackTaskQueue::~ODWaveTrackTaskQueue().
|
protected |
Number of threads currently running. Accessed thru multiple threads.
Definition at line 162 of file ODManager.h.
Referenced by DecrementCurrentThreads(), Init(), and Start().
|
protected |
Definition at line 164 of file ODManager.h.
Referenced by DecrementCurrentThreads(), and Start().
|
protected |
Maximum number of threads allowed out.
Definition at line 167 of file ODManager.h.
|
protected |
Definition at line 159 of file ODManager.h.
Referenced by Start().
|
protected |
Definition at line 156 of file ODManager.h.
Referenced by AddTask(), ODManager(), SignalTaskQueueLoop(), and Start().
|
protected |
Definition at line 157 of file ODManager.h.
Referenced by AddTask(), SignalTaskQueueLoop(), and Start().
|
protected |
Definition at line 177 of file ODManager.h.
Referenced by AddTask(), ODManager(), SignalTaskQueueLoop(), Start(), and ~ODManager().
|
protected |
Definition at line 176 of file ODManager.h.
Referenced by ODManager(), Start(), and ~ODManager().
|
protected |
Definition at line 147 of file ODManager.h.
Referenced by AddNewTask(), DemandTrackUpdate(), FillTipForWaveTrack(), GetOverallPercentComplete(), GetTotalNumTasks(), MakeWaveTrackDependent(), MakeWaveTrackIndependent(), ReplaceWaveTrack(), Start(), UpdateQueues(), and ~ODManager().
|
protected |
Definition at line 148 of file ODManager.h.
Referenced by AddNewTask(), DemandTrackUpdate(), FillTipForWaveTrack(), GetOverallPercentComplete(), GetTotalNumTasks(), MakeWaveTrackDependent(), MakeWaveTrackIndependent(), ReplaceWaveTrack(), Start(), and UpdateQueues().
|
protected |
Definition at line 151 of file ODManager.h.
Referenced by AddTask(), RemoveTaskIfInQueue(), and Start().
|
protected |
Definition at line 153 of file ODManager.h.
Referenced by AddTask(), RemoveTaskIfInQueue(), and Start().
|
protected |
Definition at line 169 of file ODManager.h.
Referenced by ODManager(), Start(), and ~ODManager().
|
protected |
Definition at line 172 of file ODManager.h.
Referenced by ODManager(), Start(), and ~ODManager().
|
protected |
Definition at line 173 of file ODManager.h.
Referenced by Start(), and ~ODManager().
|
protected |
Definition at line 170 of file ODManager.h.
Referenced by Start(), and ~ODManager().
|
staticprotected |
Definition at line 144 of file ODManager.h.
Referenced by InstanceFirstTime(), InstanceNormal(), ODManager::Pauser::Pause(), and Quit().