9 #ifndef __PDG_GRAPH_CONTEXT_H__
10 #define __PDG_GRAPH_CONTEXT_H__
45 class PDG_InProcessScheduler;
49 class PDG_ServiceScheduler;
75 virtual
void onPDGGraphContextRegistered(
77 virtual
void onPDGGraphContextDeregistered(
98 static
void addGraphContextObserver(
Observer *observer);
99 static
void removeGraphContextObserver(
Observer *observer);
105 const char* name="context",
114 int64 getMemoryUsage(
115 bool inclusive)
const override;
121 bool inclusive)
const;
125 { myAppGraph = graph; }
133 {
return myEventQueue.get(); }
137 {
return &myCheckpointManager; }
148 bool defaultWorkItemLabel(
154 {
return myCookState; }
158 {
return myCooking; }
163 {
return myCanceling; }
170 {
return myDefaultScheduler; }
175 {
return myServiceScheduler; }
180 {
return myInProcessScheduler; }
197 bool removeScheduler(
201 void setDefaultScheduler(
211 const SchedulerMap& schedulers()
const;
219 void cleanTempDirectory(
257 int stateCount()
const;
260 int chunkDepth()
const;
263 void commandDescriptions(
274 void serializeWorkItems(
287 bool pretty_print)
const;
295 bool deserializeCheckpoint(
301 void beginDeserialization();
308 void addWorkItemDependency(
315 void addWorkItemDependencyId(
332 void addWorkItemResults(
341 void addWorkItemResultsId(
357 template <
typename Func>
364 auto it = theContextMap.find(name);
365 if (it != theContextMap.end())
370 template <
typename Func>
375 for (
auto&& entry : theContextMap)
380 template<
typename Func>
388 auto it = mySchedulers.find(name);
389 if (it != mySchedulers.end())
390 func(it->second.get());
394 bool preEvaluation()
override;
395 bool tickEvaluation()
override;
398 bool canceled)
override;
403 static void onExit(
void*
data);
404 static void onPyExit();
405 static void* doTickThread(
void*
data);
407 void commitWorkItemInternal(
409 void addWorkItemDependencyInternal(
414 void addWorkItemResultsInternal(
422 void serializeWorkItem(
426 void serializeWorkItemCommit(
438 static ContextMap theContextMap;
440 static ObserverSet theObservers;
442 static bool theRegisteredAtExit;
453 mutable UT_Lock mySchedulersLock;
454 SchedulerMap mySchedulers;
457 PDG_ServiceScheduler* myServiceScheduler;
458 PDG_InProcessScheduler* myInProcessScheduler;
State
The state of the evaluator object.
PDG_ServiceScheduler * serviceScheduler() const
PDG_CheckpointManager * checkpointManager()
Returns the checkpoint manager associated with this instance.
GLuint GLsizei const GLchar * label
UT_SharedPtr< PDG_Scheduler > PDG_SchedulerPtr
PDG_InProcessScheduler * inProcessScheduler() const
static void safeGraphContextAccess(const UT_StringHolder &name, const Func &func)
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
int id() const
Returns the id of the graph context.
void addWorkItemPropagateDep(const UT_StringHolder &item_name, const UT_StringHolder &dep_name)
Adds a propagate dependency between two work iems, given their names.
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
void addWorkItemPropagateDepId(PDG_WorkItemID item_id, PDG_WorkItemID dep_id)
Adds a propagate dependency between two work iems, given their IDs.
static void safeGraphContextAccess(const Func &func)
Runs a function over all graph contexts with the context lock held.
bool cooking() const
Returns true if the context is actively cooking.
void safeSchedulerAccess(const UT_StringHolder &name, const Func &func)
Runs a function with the scheduler lock held.
GLuint const GLchar * name
PDG_EventQueue * getEventQueue()
Returns the event queue associted with this context.
const PDG_CookState & cookState() const
PDG_Graph * graph()
The graph owned by this instance.
exint PDG_WorkItemID
Type defs for unique work item IDs.
PDG_Scheduler * defaultScheduler() const
const UT_StringHolder & name() const
The unique name of the graph context.