Audacity  2.2.2
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
ODTask Class Referenceabstract

A class representing a modular task to be used with the On-Demand structures. More...

#include <ODTask.h>

Inheritance diagram for ODTask:
ODComputeSummaryTask ODDecodeTask ODDecodeFlacTask

Public Types

enum  {
  eODNone = 0x00000000, eODFLAC = 0x00000001, eODMP3 = 0x00000002, eODFFMPEG = 0x00000004,
  eODPCMSummary = 0x00001000, eODOTHER = 0x10000000
}
 

Public Member Functions

 ODTask ()
 Constructs an ODTask. More...
 
virtual ~ODTask ()
 
virtual std::unique_ptr< ODTaskClone () const =0
 
virtual unsigned int GetODType ()
 Subclasses should override to return respective type. More...
 
void DoSome (float amountWork=0.0)
 
void DoAll ()
 Call DoSome until PercentComplete >= 1.0. More...
 
virtual float PercentComplete ()
 return the amount of the task that has been completed. 0.0 to 1.0 More...
 
virtual bool UsesCustomWorkUntilPercentage ()
 
virtual float ComputeNextWorkUntilPercentageComplete ()
 
virtual bool CanMergeWith (ODTask *otherTask)
 
virtual void StopUsingWaveTrack (WaveTrack *track)
 
virtual void ReplaceWaveTrack (WaveTrack *oldTrack, WaveTrack *newTrack)
 Replaces all instances to a wavetrack with a NEW one, effectively transferring the task. More...
 
void AddWaveTrack (WaveTrack *track)
 Adds a WaveTrack to do the task for. More...
 
virtual int GetNumWaveTracks ()
 
virtual WaveTrackGetWaveTrack (int i)
 
virtual 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...
 
bool IsComplete ()
 return More...
 
void TerminateAndBlock ()
 
virtual void Terminate ()
 releases memory that the ODTask owns. Subclasses should override. More...
 
virtual const char * GetTaskName ()
 
virtual sampleCount GetDemandSample () const
 
virtual void SetDemandSample (sampleCount sample)
 
virtual void RecalculatePercentComplete ()
 does an od update and then recalculates the data. More...
 
int GetTaskNumber ()
 returns the number of tasks created before this instance. More...
 
void SetNeedsODUpdate ()
 
bool GetNeedsODUpdate ()
 
void ResetNeedsODUpdate ()
 
virtual const wxChar * GetTip ()=0
 
virtual bool IsTaskAssociatedWithProject (AudacityProject *proj)
 returns true if the task is associated with the project. More...
 
bool IsRunning ()
 

Public Attributes

enum ODTask:: { ... }  ODTypeEnum
 

Protected Member Functions

virtual void CalculatePercentComplete ()=0
 calculates the percentage complete from existing data. More...
 
virtual void DoSomeInternal ()=0
 
virtual void Update ()
 virtual method called before DoSomeInternal is used from DoSome. More...
 
virtual void ODUpdate ()
 
void SetIsRunning (bool value)
 

Protected Attributes

int mTaskNumber
 
volatile float mPercentComplete
 
ODLock mPercentCompleteMutex
 
volatile bool mDoingTask
 
volatile bool mTaskStarted
 
volatile bool mTerminate
 
ODLock mTerminateMutex
 
ODLock mBlockUntilTerminateMutex
 
std::vector< WaveTrack * > mWaveTracks
 
ODLock mWaveTrackMutex
 
sampleCount mDemandSample
 
ODLock mDemandSampleMutex
 
volatile bool mIsRunning
 
ODLock mIsRunningMutex
 

Private Attributes

volatile bool mNeedsODUpdate
 
ODLock mNeedsODUpdateMutex
 

Detailed Description

A class representing a modular task to be used with the On-Demand structures.

ODTask is an abstract class that outlines the methods that will be used to support On-Demand background loading of files. These ODTasks are generally meant to be run in a background thread.

Definition at line 39 of file ODTask.h.

Member Enumeration Documentation

anonymous enum
Enumerator
eODNone 
eODFLAC 
eODMP3 
eODFFMPEG 
eODPCMSummary 
eODOTHER 

Definition at line 42 of file ODTask.h.

42  {
43  eODNone = 0x00000000,
44  eODFLAC = 0x00000001,
45  eODMP3 = 0x00000002,
46  eODFFMPEG = 0x00000004,
47  eODPCMSummary = 0x00001000,
48  eODOTHER = 0x10000000,
49  } ODTypeEnum;
enum ODTask::@53 ODTypeEnum

Constructor & Destructor Documentation

ODTask::ODTask ( )

Constructs an ODTask.

Definition at line 33 of file ODTask.cpp.

34 : mDemandSample(0)
35 {
36 
37  static int sTaskNumber=0;
39  mDoingTask=false;
40  mTerminate = false;
41  mNeedsODUpdate=false;
42  mIsRunning = false;
43 
44  mTaskNumber=sTaskNumber++;
45 }
volatile bool mNeedsODUpdate
Definition: ODTask.h:171
volatile bool mIsRunning
Definition: ODTask.h:165
volatile float mPercentComplete
Definition: ODTask.h:150
volatile bool mDoingTask
Definition: ODTask.h:152
sampleCount mDemandSample
Definition: ODTask.h:162
int mTaskNumber
Definition: ODTask.h:149
volatile bool mTerminate
Definition: ODTask.h:154
virtual ODTask::~ODTask ( )
inlinevirtual

Definition at line 55 of file ODTask.h.

55 {};

Member Function Documentation

void ODTask::AddWaveTrack ( WaveTrack track)

Adds a WaveTrack to do the task for.

Sets the wavetrack that will be analyzed for ODPCMAliasBlockFiles that will have their summaries computed and written to disk.

Definition at line 273 of file ODTask.cpp.

References mWaveTracks.

Referenced by AudacityProject::EnqueueODTasks(), and AudacityProject::PopState().

274 {
275  mWaveTracks.push_back(track);
276 }
std::vector< WaveTrack * > mWaveTracks
Definition: ODTask.h:159
virtual void ODTask::CalculatePercentComplete ( )
protectedpure virtual

calculates the percentage complete from existing data.

Implemented in ODDecodeTask, and ODComputeSummaryTask.

Referenced by RecalculatePercentComplete().

virtual bool ODTask::CanMergeWith ( ODTask otherTask)
inlinevirtual

returns whether or not this task and another task can merge together, as when we make two mono tracks stereo. for Loading/Summarizing, this is not an issue because the entire track is processed Effects that affect portions of a track will need to check this.

Definition at line 81 of file ODTask.h.

References GetTaskName().

81 {return strcmp(GetTaskName(),otherTask->GetTaskName())==0;}
virtual const char * GetTaskName()
Definition: ODTask.h:103
virtual std::unique_ptr<ODTask> ODTask::Clone ( ) const
pure virtual

Implemented in ODDecodeFlacTask, and ODComputeSummaryTask.

virtual float ODTask::ComputeNextWorkUntilPercentageComplete ( )
inlinevirtual

Reimplemented in ODComputeSummaryTask.

Definition at line 76 of file ODTask.h.

Referenced by DoSome().

76 {return 1.0;}
void ODTask::DemandTrackUpdate ( WaveTrack track,
double  seconds 
)
virtual

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

Parameters
trackthe track to update
secondsthe point in the track from which the tasks associated with track should begin processing from.

Reimplemented in ODDecodeTask.

Definition at line 324 of file ODTask.cpp.

References GetDemandSample(), WaveTrack::GetRate(), mWaveTrackMutex, mWaveTracks, SetDemandSample(), and SetNeedsODUpdate().

Referenced by ODDecodeTask::DemandTrackUpdate().

325 {
326  bool demandSampleChanged=false;
327  mWaveTrackMutex.Lock();
328  for(size_t i=0;i<mWaveTracks.size();i++)
329  {
330  if(track == mWaveTracks[i])
331  {
332  auto newDemandSample = (sampleCount)(seconds * track->GetRate());
333  demandSampleChanged = newDemandSample != GetDemandSample();
334  SetDemandSample(newDemandSample);
335  break;
336  }
337  }
338  mWaveTrackMutex.Unlock();
339 
340  if(demandSampleChanged)
342 
343 }
virtual sampleCount GetDemandSample() const
Definition: ODTask.cpp:227
ODLock mWaveTrackMutex
Definition: ODTask.h:160
virtual void SetDemandSample(sampleCount sample)
Definition: ODTask.cpp:236
std::vector< WaveTrack * > mWaveTracks
Definition: ODTask.h:159
void SetNeedsODUpdate()
Definition: ODTask.cpp:289
double GetRate() const
Definition: WaveTrack.cpp:398
void ODTask::DoAll ( )

Call DoSome until PercentComplete >= 1.0.

void ODTask::DoSome ( float  amountWork = 0.0)

Do a modular part of the task. For example, if the task is to load the entire file, load one BlockFile. Relies on DoSomeInternal(), which is the subclasses must implement.

Parameters
amountWorkthe percent amount of the total job to do. 1.0 represents the entire job. the default of 0.0 will do the smallest unit of work possible

Definition at line 69 of file ODTask.cpp.

References ODManager::AddTask(), AudacityProject::AllProjectDeleteMutex(), ComputeNextWorkUntilPercentageComplete(), DoSomeInternal(), gAudacityProjects, GetNeedsODUpdate(), ODManager::Instance, IsTaskAssociatedWithProject(), mBlockUntilTerminateMutex, mDoingTask, mTaskStarted, mTerminate, mTerminateMutex, ODUpdate(), PercentComplete(), SetIsRunning(), Update(), and UsesCustomWorkUntilPercentage().

70 {
71  SetIsRunning(true);
73 
74 // wxPrintf("%s %i subtask starting on NEW thread with priority\n", GetTaskName(),GetTaskNumber());
75 
77 
78  float workUntil = amountWork+PercentComplete();
79 
80 
81 
82  //check periodically to see if we should exit.
83  mTerminateMutex.Lock();
84  if(mTerminate)
85  {
86  mTerminateMutex.Unlock();
87  SetIsRunning(false);
89  return;
90  }
91  mTerminateMutex.Unlock();
92 
93  Update();
94 
95 
98 
99  if(workUntil<PercentComplete())
100  workUntil = PercentComplete();
101 
102  //Do Some of the task.
103 
104  mTerminateMutex.Lock();
105  while(PercentComplete() < workUntil && PercentComplete() < 1.0 && !mTerminate)
106  {
107  wxThread::This()->Yield();
108  //release within the loop so we can cut the number of iterations short
109 
110  DoSomeInternal(); //keep the terminate mutex on so we don't remo
111  mTerminateMutex.Unlock();
112  //check to see if ondemand has been called
113  if(GetNeedsODUpdate() && PercentComplete() < 1.0)
114  ODUpdate();
115 
116 
117  //But add the mutex lock back before we check the value again.
118  mTerminateMutex.Lock();
119  }
120  mTerminateMutex.Unlock();
121  mDoingTask=false;
122 
123  mTerminateMutex.Lock();
124  //if it is not done, put it back onto the ODManager queue.
125  if(PercentComplete() < 1.0&& !mTerminate)
126  {
127  ODManager::Instance()->AddTask(this);
128 
129  //we did a bit of progress - we should allow a resave.
131  for(unsigned i=0; i<gAudacityProjects.size(); i++)
132  {
134  {
135  //mark the changes so that the project can be resaved.
136  gAudacityProjects[i]->GetUndoManager()->SetODChangesFlag();
137  break;
138  }
139  }
140 
141 
142 // wxPrintf("%s %i is %f done\n", GetTaskName(),GetTaskNumber(),PercentComplete());
143  }
144  else
145  {
146  //for profiling, uncomment and look in audacity.app/exe's folder for AudacityProfile.txt
147  //static int tempLog =0;
148  //if(++tempLog % 5==0)
149  //END_TASK_PROFILING("On Demand Drag and Drop 5 80 mb files into audacity, 5 wavs per task");
150  //END_TASK_PROFILING("On Demand open an 80 mb wav stereo file");
151 
152  wxCommandEvent event( EVT_ODTASK_COMPLETE );
153 
155  for(unsigned i=0; i<gAudacityProjects.size(); i++)
156  {
158  {
159  //this assumes tasks are only associated with one project.
160  gAudacityProjects[i]->GetEventHandler()->AddPendingEvent(event);
161  //mark the changes so that the project can be resaved.
162  gAudacityProjects[i]->GetUndoManager()->SetODChangesFlag();
163  break;
164  }
165  }
166 
167 // wxPrintf("%s %i complete\n", GetTaskName(),GetTaskNumber());
168  }
169  mTerminateMutex.Unlock();
170  SetIsRunning(false);
171  mBlockUntilTerminateMutex.Unlock();
172 }
static ODManager *(* Instance)()
Definition: ODManager.h:49
ODLock mTerminateMutex
Definition: ODTask.h:155
AProjectArray gAudacityProjects
Definition: Project.cpp:303
virtual void ODUpdate()
Definition: ODTask.cpp:205
virtual void Update()
virtual method called before DoSomeInternal is used from DoSome.
Definition: ODTask.h:138
void SetIsRunning(bool value)
Definition: ODTask.cpp:211
bool GetNeedsODUpdate()
Definition: ODTask.cpp:295
virtual float PercentComplete()
return the amount of the task that has been completed. 0.0 to 1.0
Definition: ODTask.cpp:246
virtual bool IsTaskAssociatedWithProject(AudacityProject *proj)
returns true if the task is associated with the project.
Definition: ODTask.cpp:174
void AddTask(ODTask *task)
Adds a task to the running queue. Threas-safe.
Definition: ODManager.cpp:95
volatile bool mDoingTask
Definition: ODTask.h:152
static ODLock & AllProjectDeleteMutex()
Prevents DELETE from external thread - for e.g. use of GetActiveProject.
Definition: Project.cpp:183
ODLock mBlockUntilTerminateMutex
Definition: ODTask.h:157
virtual float ComputeNextWorkUntilPercentageComplete()
Definition: ODTask.h:76
volatile bool mTaskStarted
Definition: ODTask.h:153
virtual void DoSomeInternal()=0
volatile bool mTerminate
Definition: ODTask.h:154
virtual bool UsesCustomWorkUntilPercentage()
Definition: ODTask.h:75
virtual void ODTask::DoSomeInternal ( )
protectedpure virtual

pure virtual function that does some part of the task this object represents. this function is meant to be called repeatedly until the IsComplete is true. Does the smallest unit of work for this task.

Implemented in ODDecodeTask, and ODComputeSummaryTask.

Referenced by DoSome().

sampleCount ODTask::GetDemandSample ( ) const
virtual

Definition at line 227 of file ODTask.cpp.

References mDemandSample, and mDemandSampleMutex.

Referenced by ODComputeSummaryTask::Clone(), ODDecodeFlacTask::Clone(), and DemandTrackUpdate().

228 {
229  sampleCount retval;
230  mDemandSampleMutex.Lock();
231  retval = mDemandSample;
232  mDemandSampleMutex.Unlock();
233  return retval;
234 }
ODLock mDemandSampleMutex
Definition: ODTask.h:163
sampleCount mDemandSample
Definition: ODTask.h:162
bool ODTask::GetNeedsODUpdate ( )

Definition at line 295 of file ODTask.cpp.

References mNeedsODUpdate, and mNeedsODUpdateMutex.

Referenced by DoSome(), and RecalculatePercentComplete().

296 {
297  bool ret;
298  mNeedsODUpdateMutex.Lock();
299  ret=mNeedsODUpdate;
300  mNeedsODUpdateMutex.Unlock();
301  return ret;
302 }
volatile bool mNeedsODUpdate
Definition: ODTask.h:171
ODLock mNeedsODUpdateMutex
Definition: ODTask.h:172
int ODTask::GetNumWaveTracks ( )
virtual

Definition at line 279 of file ODTask.cpp.

References mWaveTrackMutex, and mWaveTracks.

Referenced by ODWaveTrackTaskQueue::AddTask().

280 {
281  int num;
282  mWaveTrackMutex.Lock();
283  num = (int)mWaveTracks.size();
284  mWaveTrackMutex.Unlock();
285  return num;
286 }
ODLock mWaveTrackMutex
Definition: ODTask.h:160
std::vector< WaveTrack * > mWaveTracks
Definition: ODTask.h:159
virtual unsigned int ODTask::GetODType ( )
inlinevirtual

Subclasses should override to return respective type.

Reimplemented in ODDecodeFlacTask, ODDecodeTask, and ODComputeSummaryTask.

Definition at line 61 of file ODTask.h.

61 {return eODNone;}
virtual const char* ODTask::GetTaskName ( )
inlinevirtual

Reimplemented in ODDecodeTask, and ODComputeSummaryTask.

Definition at line 103 of file ODTask.h.

Referenced by CanMergeWith().

103 {return "ODTask";}
int ODTask::GetTaskNumber ( )
inline

returns the number of tasks created before this instance.

Definition at line 113 of file ODTask.h.

113 {return mTaskNumber;}
int mTaskNumber
Definition: ODTask.h:149
virtual const wxChar* ODTask::GetTip ( )
pure virtual

Implemented in ODDecodeTask, and ODComputeSummaryTask.

WaveTrack * ODTask::GetWaveTrack ( int  i)
virtual

Definition at line 261 of file ODTask.cpp.

References mWaveTrackMutex, and mWaveTracks.

Referenced by ODWaveTrackTaskQueue::AddTask().

262 {
263  WaveTrack* track = NULL;
264  mWaveTrackMutex.Lock();
265  if(i<(int)mWaveTracks.size())
266  track = mWaveTracks[i];
267  mWaveTrackMutex.Unlock();
268  return track;
269 }
ODLock mWaveTrackMutex
Definition: ODTask.h:160
std::vector< WaveTrack * > mWaveTracks
Definition: ODTask.h:159
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
bool ODTask::IsComplete ( )

return

Definition at line 255 of file ODTask.cpp.

References IsRunning(), and PercentComplete().

256 {
257  return PercentComplete() >= 1.0 && !IsRunning();
258 }
bool IsRunning()
Definition: ODTask.cpp:218
virtual float PercentComplete()
return the amount of the task that has been completed. 0.0 to 1.0
Definition: ODTask.cpp:246
bool ODTask::IsRunning ( )

Definition at line 218 of file ODTask.cpp.

References mIsRunning, and mIsRunningMutex.

Referenced by IsComplete().

219 {
220  bool ret;
221  mIsRunningMutex.Lock();
222  ret= mIsRunning;
223  mIsRunningMutex.Unlock();
224  return ret;
225 }
volatile bool mIsRunning
Definition: ODTask.h:165
ODLock mIsRunningMutex
Definition: ODTask.h:166
bool ODTask::IsTaskAssociatedWithProject ( AudacityProject proj)
virtual

returns true if the task is associated with the project.

Definition at line 174 of file ODTask.cpp.

References TrackListIterator::First(), Track::GetKind(), AudacityProject::GetTracks(), mWaveTrackMutex, mWaveTracks, TrackListIterator::Next(), and Track::Wave.

Referenced by DoSome().

175 {
176  TrackList *tracks = proj->GetTracks();
177  TrackListIterator iter1(tracks);
178  Track *tr = iter1.First();
179 
180  while (tr)
181  {
182  //go over all tracks in the project
183  if (tr->GetKind() == Track::Wave)
184  {
185  //look inside our task's track list for one that matches this projects one.
186  mWaveTrackMutex.Lock();
187  for(int i=0;i<(int)mWaveTracks.size();i++)
188  {
189  if(mWaveTracks[i]==tr)
190  {
191  //if we find one, then the project is associated with us;return true
192  mWaveTrackMutex.Unlock();
193  return true;
194  }
195  }
196  mWaveTrackMutex.Unlock();
197  }
198  tr = iter1.Next();
199  }
200 
201  return false;
202 
203 }
A list of TrackListNode items.
Definition: Track.h:619
ODLock mWaveTrackMutex
Definition: ODTask.h:160
std::vector< WaveTrack * > mWaveTracks
Definition: ODTask.h:159
virtual int GetKind() const
Definition: Track.h:330
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
An iterator for a TrackList.
Definition: Track.h:402
TrackList * GetTracks()
Definition: Project.h:192
void ODTask::ODUpdate ( )
protectedvirtual

virtual method called in DoSome everytime the user has demanded some OD function so that the ODTask can readjust its computation order. By default just calls Update(), but subclasses with special needs can override this

Definition at line 205 of file ODTask.cpp.

References ResetNeedsODUpdate(), and Update().

Referenced by DoSome(), and RecalculatePercentComplete().

206 {
207  Update();
209 }
virtual void Update()
virtual method called before DoSomeInternal is used from DoSome.
Definition: ODTask.h:138
void ResetNeedsODUpdate()
Definition: ODTask.cpp:304
float ODTask::PercentComplete ( )
virtual

return the amount of the task that has been completed. 0.0 to 1.0

Definition at line 246 of file ODTask.cpp.

References mPercentComplete, and mPercentCompleteMutex.

Referenced by DoSome(), and IsComplete().

247 {
248  mPercentCompleteMutex.Lock();
249  float ret = mPercentComplete;
250  mPercentCompleteMutex.Unlock();
251  return ret;
252 }
volatile float mPercentComplete
Definition: ODTask.h:150
ODLock mPercentCompleteMutex
Definition: ODTask.h:151
void ODTask::RecalculatePercentComplete ( )
virtual

does an od update and then recalculates the data.

Definition at line 312 of file ODTask.cpp.

References CalculatePercentComplete(), GetNeedsODUpdate(), and ODUpdate().

313 {
314  if(GetNeedsODUpdate())
315  {
316  ODUpdate();
318  }
319 }
virtual void ODUpdate()
Definition: ODTask.cpp:205
virtual void CalculatePercentComplete()=0
calculates the percentage complete from existing data.
bool GetNeedsODUpdate()
Definition: ODTask.cpp:295
void ODTask::ReplaceWaveTrack ( WaveTrack oldTrack,
WaveTrack newTrack 
)
virtual

Replaces all instances to a wavetrack with a NEW one, effectively transferring the task.

Replaces all instances to a wavetrack with a NEW one, effectively transferring the task. ODTask has no wavetrack, so it does nothing. But subclasses that do should override this.

Definition at line 358 of file ODTask.cpp.

References mWaveTrackMutex, and mWaveTracks.

359 {
360  mWaveTrackMutex.Lock();
361  for(size_t i=0;i<mWaveTracks.size();i++)
362  {
363  if(oldTrack == mWaveTracks[i])
364  {
365  mWaveTracks[i] = newTrack;
366  }
367  }
368  mWaveTrackMutex.Unlock();
369 }
ODLock mWaveTrackMutex
Definition: ODTask.h:160
std::vector< WaveTrack * > mWaveTracks
Definition: ODTask.h:159
void ODTask::ResetNeedsODUpdate ( )

Definition at line 304 of file ODTask.cpp.

References mNeedsODUpdate, and mNeedsODUpdateMutex.

Referenced by ODUpdate().

305 {
306  mNeedsODUpdateMutex.Lock();
307  mNeedsODUpdate=false;
308  mNeedsODUpdateMutex.Unlock();
309 }
volatile bool mNeedsODUpdate
Definition: ODTask.h:171
ODLock mNeedsODUpdateMutex
Definition: ODTask.h:172
void ODTask::SetDemandSample ( sampleCount  sample)
virtual

Definition at line 236 of file ODTask.cpp.

References mDemandSample, and mDemandSampleMutex.

Referenced by DemandTrackUpdate().

237 {
238 
239  mDemandSampleMutex.Lock();
240  mDemandSample=sample;
241  mDemandSampleMutex.Unlock();
242 }
ODLock mDemandSampleMutex
Definition: ODTask.h:163
sampleCount mDemandSample
Definition: ODTask.h:162
void ODTask::SetIsRunning ( bool  value)
protected

Definition at line 211 of file ODTask.cpp.

References mIsRunning, and mIsRunningMutex.

Referenced by DoSome().

212 {
213  mIsRunningMutex.Lock();
214  mIsRunning=value;
215  mIsRunningMutex.Unlock();
216 }
volatile bool mIsRunning
Definition: ODTask.h:165
ODLock mIsRunningMutex
Definition: ODTask.h:166
void ODTask::SetNeedsODUpdate ( )

Definition at line 289 of file ODTask.cpp.

References mNeedsODUpdate, and mNeedsODUpdateMutex.

Referenced by DemandTrackUpdate().

290 {
291  mNeedsODUpdateMutex.Lock();
292  mNeedsODUpdate=true;
293  mNeedsODUpdateMutex.Unlock();
294 }
volatile bool mNeedsODUpdate
Definition: ODTask.h:171
ODLock mNeedsODUpdateMutex
Definition: ODTask.h:172
void ODTask::StopUsingWaveTrack ( WaveTrack track)
virtual

Definition at line 346 of file ODTask.cpp.

References mWaveTrackMutex, and mWaveTracks.

347 {
348  mWaveTrackMutex.Lock();
349  for(size_t i=0;i<mWaveTracks.size();i++)
350  {
351  if(mWaveTracks[i] == track)
352  mWaveTracks[i]=NULL;
353  }
354  mWaveTrackMutex.Unlock();
355 }
ODLock mWaveTrackMutex
Definition: ODTask.h:160
std::vector< WaveTrack * > mWaveTracks
Definition: ODTask.h:159
virtual void ODTask::Terminate ( )
inlinevirtual

releases memory that the ODTask owns. Subclasses should override.

Reimplemented in ODComputeSummaryTask.

Definition at line 101 of file ODTask.h.

Referenced by TerminateAndBlock().

101 {}
void ODTask::TerminateAndBlock ( )

Definition at line 48 of file ODTask.cpp.

References mBlockUntilTerminateMutex, mTerminate, mTerminateMutex, and Terminate().

49 {
50  //one mutex pair for the value of mTerminate
51  mTerminateMutex.Lock();
52  mTerminate=true;
53  //release all data the derived class may have allocated
54  mTerminateMutex.Unlock();
55 
56  //and one mutex pair for the exit of the function
58 //TODO lock mTerminate?
60 
61  //wait till we are out of doSome() to terminate.
62  Terminate();
63 }
ODLock mTerminateMutex
Definition: ODTask.h:155
ODLock mBlockUntilTerminateMutex
Definition: ODTask.h:157
virtual void Terminate()
releases memory that the ODTask owns. Subclasses should override.
Definition: ODTask.h:101
volatile bool mTerminate
Definition: ODTask.h:154
virtual void ODTask::Update ( )
inlineprotectedvirtual

virtual method called before DoSomeInternal is used from DoSome.

Reimplemented in ODDecodeTask, and ODComputeSummaryTask.

Definition at line 138 of file ODTask.h.

Referenced by DoSome(), and ODUpdate().

138 {}
virtual bool ODTask::UsesCustomWorkUntilPercentage ( )
inlinevirtual

Reimplemented in ODComputeSummaryTask.

Definition at line 75 of file ODTask.h.

Referenced by DoSome().

75 {return false;}

Member Data Documentation

ODLock ODTask::mBlockUntilTerminateMutex
protected

Definition at line 157 of file ODTask.h.

Referenced by DoSome(), and TerminateAndBlock().

sampleCount ODTask::mDemandSample
protected

Definition at line 162 of file ODTask.h.

Referenced by GetDemandSample(), and SetDemandSample().

ODLock ODTask::mDemandSampleMutex
mutableprotected

Definition at line 163 of file ODTask.h.

Referenced by GetDemandSample(), and SetDemandSample().

volatile bool ODTask::mDoingTask
protected

Definition at line 152 of file ODTask.h.

Referenced by DoSome().

volatile bool ODTask::mIsRunning
protected

Definition at line 165 of file ODTask.h.

Referenced by IsRunning(), and SetIsRunning().

ODLock ODTask::mIsRunningMutex
protected

Definition at line 166 of file ODTask.h.

Referenced by IsRunning(), and SetIsRunning().

volatile bool ODTask::mNeedsODUpdate
private

Definition at line 171 of file ODTask.h.

Referenced by GetNeedsODUpdate(), ResetNeedsODUpdate(), and SetNeedsODUpdate().

ODLock ODTask::mNeedsODUpdateMutex
private

Definition at line 172 of file ODTask.h.

Referenced by GetNeedsODUpdate(), ResetNeedsODUpdate(), and SetNeedsODUpdate().

volatile float ODTask::mPercentComplete
protected
ODLock ODTask::mPercentCompleteMutex
protected
int ODTask::mTaskNumber
protected

Definition at line 149 of file ODTask.h.

volatile bool ODTask::mTaskStarted
protected

Definition at line 153 of file ODTask.h.

Referenced by DoSome().

volatile bool ODTask::mTerminate
protected

Definition at line 154 of file ODTask.h.

Referenced by DoSome(), and TerminateAndBlock().

ODLock ODTask::mTerminateMutex
protected

Definition at line 155 of file ODTask.h.

Referenced by DoSome(), and TerminateAndBlock().

ODLock ODTask::mWaveTrackMutex
protected
std::vector<WaveTrack*> ODTask::mWaveTracks
protected
enum { ... } ODTask::ODTypeEnum

The documentation for this class was generated from the following files: