1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-16 09:31:14 +01:00

RAII object for pausing and unpausing OD manager

This commit is contained in:
Paul Licameli
2016-04-12 16:16:32 -04:00
parent bd9fc44173
commit 5d28a05702
4 changed files with 17 additions and 14 deletions

View File

@@ -330,7 +330,7 @@ void ODManager::Start()
//static function that prevents ODTasks from being scheduled
//does not stop currently running tasks from completing their immediate subtask,
//but presumably they will finish within a second
void ODManager::Pause(bool pause)
void ODManager::Pauser::Pause(bool pause)
{
if(IsInstanceCreated())
{
@@ -349,7 +349,7 @@ void ODManager::Pause(bool pause)
}
}
void ODManager::Resume()
void ODManager::Pauser::Resume()
{
Pause(false);
}

View File

@@ -106,9 +106,18 @@ class ODManager final
///Get Total Number of Tasks.
int GetTotalNumTasks();
//Pause/unpause all OD Tasks. Does not occur immediately.
static void Pause(bool pause = true);
static void Resume();
// RAII object for pausing and resuming..
class Pauser
{
//Pause/unpause all OD Tasks. Does not occur immediately.
static void Pause(bool pause = true);
static void Resume();
public:
Pauser() { Pause(); }
~Pauser() { Resume(); }
Pauser(const Pauser&) PROHIBITED;
Pauser &operator= (const Pauser&) PROHIBITED;
};
static void LockLibSndFileMutex();
static void UnlockLibSndFileMutex();