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 -------------------------------------------------------------------------*/ 00047 #ifndef __vtkExecutionScheduler_h 00048 #define __vtkExecutionScheduler_h 00049 00050 #include "vtkObject.h" 00051 #include "vtkExecutionSchedulerManager.h" // For singleton instantiation/cleanup 00052 00053 class vtkExecutive; 00054 class vtkComputingResources; 00055 class vtkMultiThreader; 00056 class vtkMutexLock; 00057 class vtkThreadMessager; 00058 class vtkInformation; 00059 class vtkInformationIntegerKey; 00060 class vtkExecutiveCollection; 00061 00062 class VTK_FILTERING_EXPORT vtkExecutionScheduler : public vtkObject 00063 { 00064 public: 00065 static vtkExecutionScheduler* New(); 00066 vtkTypeMacro(vtkExecutionScheduler,vtkObject); 00067 void PrintSelf(ostream &os, vtkIndent indent); 00068 00070 static vtkExecutionScheduler *GetGlobalScheduler(); 00071 00073 static vtkInformationIntegerKey* TASK_PRIORITY(); 00074 00078 void Schedule(vtkExecutiveCollection *execs, vtkInformation *info); 00079 00083 void SchedulePropagate(vtkExecutiveCollection *execs, vtkInformation *info); 00084 00087 void WaitUntilDone(vtkExecutiveCollection *execs); 00088 00091 void WaitUntilReleased(vtkExecutiveCollection *execs); 00092 00094 void WaitUntilAllDone(); 00095 00099 void WaitForTaskDone(vtkExecutive *exec); 00100 00103 void WaitForInputsReleased(vtkExecutive *exec); 00104 00107 vtkThreadMessager* GetTaskDoneMessager(vtkExecutive *exec); 00108 00111 vtkThreadMessager* GetInputsReleasedMessager(vtkExecutive *exec); 00112 00115 vtkMutexLock* GetInputsReleasedLock(vtkExecutive *exec); 00116 00118 void ReleaseResources(vtkExecutive *exec); 00119 00121 void ReacquireResources(vtkExecutive *exec); 00122 00125 void RescheduleNetwork(vtkExecutive *sink); 00126 00129 void RescheduleFrom(vtkExecutive *sink, vtkComputingResources *resources); 00130 00131 protected: 00132 vtkExecutionScheduler(); 00133 ~vtkExecutionScheduler(); 00134 00135 vtkComputingResources *Resources; 00136 vtkThreadMessager *ScheduleMessager; 00137 vtkThreadMessager *ResourceMessager; 00138 vtkMutexLock *ScheduleLock; 00139 vtkMultiThreader *ScheduleThreader; 00140 int ScheduleThreadId; 00141 00142 //BTX 00143 class implementation; 00144 implementation* const Implementation; 00145 friend class implementation; 00146 00149 friend void * vtkExecutionScheduler_ScheduleThread(void *data); 00150 00153 friend void * vtkExecutionScheduler_ExecuteThread(void *data); 00154 00155 //ETX 00156 00158 00159 static void ClassInitialize(); 00160 static void ClassFinalize(); 00161 friend class vtkExecutionSchedulerManager; 00163 00164 private: 00165 vtkExecutionScheduler(const vtkExecutionScheduler&); // Not implemented. 00166 void operator=(const vtkExecutionScheduler&); // Not implemented. 00167 00168 }; 00169 00170 #endif