VTK
dox/Common/ExecutionModel/vtkExecutionScheduler.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkExecutionScheduler.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 /*-------------------------------------------------------------------------
00016   Copyright (c) 2008, 2009 by SCI Institute, University of Utah.
00017 
00018   This is part of the Parallel Dataflow System originally developed by
00019   Huy T. Vo and Claudio T. Silva. For more information, see:
00020 
00021   "Parallel Dataflow Scheme for Streaming (Un)Structured Data" by Huy
00022   T. Vo, Daniel K. Osmari, Brian Summa, Joao L.D. Comba, Valerio
00023   Pascucci and Claudio T. Silva, SCI Institute, University of Utah,
00024   Technical Report #UUSCI-2009-004, 2009.
00025 
00026   "Multi-Threaded Streaming Pipeline For VTK" by Huy T. Vo and Claudio
00027   T. Silva, SCI Institute, University of Utah, Technical Report
00028   #UUSCI-2009-005, 2009.
00029 -------------------------------------------------------------------------*/
00044 #ifndef __vtkExecutionScheduler_h
00045 #define __vtkExecutionScheduler_h
00046 
00047 #include "vtkCommonExecutionModelModule.h" // For export macro
00048 #include "vtkObject.h"
00049 #include "vtkExecutionSchedulerManager.h" // For singleton instantiation/cleanup
00050 
00051 class vtkExecutive;
00052 class vtkComputingResources;
00053 class vtkMultiThreader;
00054 class vtkMutexLock;
00055 class vtkThreadMessager;
00056 class vtkInformation;
00057 class vtkInformationIntegerKey;
00058 class vtkExecutiveCollection;
00059 
00060 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkExecutionScheduler : public vtkObject
00061 {
00062 public:
00063   static vtkExecutionScheduler* New();
00064   vtkTypeMacro(vtkExecutionScheduler,vtkObject);
00065   void PrintSelf(ostream &os, vtkIndent indent);
00066 
00068   static vtkExecutionScheduler *GetGlobalScheduler();
00069 
00071   static vtkInformationIntegerKey* TASK_PRIORITY();
00072 
00076   void Schedule(vtkExecutiveCollection *execs, vtkInformation *info);
00077 
00081   void SchedulePropagate(vtkExecutiveCollection *execs, vtkInformation *info);
00082 
00085   void WaitUntilDone(vtkExecutiveCollection *execs);
00086 
00089   void WaitUntilReleased(vtkExecutiveCollection *execs);
00090 
00092   void WaitUntilAllDone();
00093 
00097   void WaitForTaskDone(vtkExecutive *exec);
00098 
00101   void WaitForInputsReleased(vtkExecutive *exec);
00102 
00105   vtkThreadMessager* GetTaskDoneMessager(vtkExecutive *exec);
00106 
00109   vtkThreadMessager* GetInputsReleasedMessager(vtkExecutive *exec);
00110 
00113   vtkMutexLock* GetInputsReleasedLock(vtkExecutive *exec);
00114 
00116   void ReleaseResources(vtkExecutive *exec);
00117 
00119   void ReacquireResources(vtkExecutive *exec);
00120 
00123   void RescheduleNetwork(vtkExecutive *sink);
00124 
00127   void RescheduleFrom(vtkExecutive *sink, vtkComputingResources *resources);
00128 
00129 protected:
00130   vtkExecutionScheduler();
00131   ~vtkExecutionScheduler();
00132 
00133   vtkComputingResources       *Resources;
00134   vtkThreadMessager           *ScheduleMessager;
00135   vtkThreadMessager           *ResourceMessager;
00136   vtkMutexLock                *ScheduleLock;
00137   vtkMultiThreader            *ScheduleThreader;
00138   int                          ScheduleThreadId;
00139 
00140 //BTX
00141   class implementation;
00142   implementation* const Implementation;
00143   friend class implementation;
00144 
00147   friend void * vtkExecutionScheduler_ScheduleThread(void *data);
00148 
00151   friend void * vtkExecutionScheduler_ExecuteThread(void *data);
00152 
00153 //ETX
00154 
00156 
00157   static void ClassInitialize();
00158   static void ClassFinalize();
00159   friend class vtkExecutionSchedulerManager;
00161 
00162 private:
00163   vtkExecutionScheduler(const vtkExecutionScheduler&);  // Not implemented.
00164   void operator=(const vtkExecutionScheduler&);  // Not implemented.
00165 
00166 };
00167 
00168 #endif