9 #ifndef __PDG_GRAPH_CONTEXT_H__
10 #define __PDG_GRAPH_CONTEXT_H__
46 class PDG_InProcessScheduler;
50 class PDG_ServiceScheduler;
77 virtual
void onPDGGraphContextRegistered(
79 virtual
void onPDGGraphContextDeregistered(
106 static
void addGraphContextObserver(
Observer *observer);
107 static
void removeGraphContextObserver(
Observer *observer);
113 const
char* name="context",
122 int64 getMemoryUsage(
123 bool inclusive) const override;
129 bool inclusive) const;
133 { myAppGraph = graph; }
141 {
return myEventQueue.get(); }
145 {
return &myCheckpointManager; }
156 bool defaultWorkItemLabel(
162 {
return myCookState; }
166 {
return myCooking; }
171 {
return myCanceling; }
178 {
return myDefaultScheduler; }
183 {
return myServiceScheduler; }
188 {
return myInProcessScheduler; }
205 bool removeScheduler(
209 void setDefaultScheduler(
219 const SchedulerMap& schedulers()
const;
227 void cleanTempDirectory(
265 int stateCount()
const;
268 int chunkDepth()
const;
271 void commandDescriptions(
282 void serializeWorkItems(
295 bool pretty_print)
const;
303 bool deserializeCheckpoint(
309 void beginDeserialization();
316 void addWorkItemDependency(
323 void addWorkItemDependencyId(
340 void addWorkItemResults(
349 void addWorkItemResultsId(
365 bool skip_defaults)
const;
369 bool skip_defaults)
const;
373 bool skip_defaults)
const;
377 bool skip_defaults)
const;
391 template <
typename Func>
398 auto it = theContextMap.find(name);
399 if (it != theContextMap.end())
404 template <
typename Func>
409 for (
auto&& entry : theContextMap)
414 template<
typename Func>
422 auto it = mySchedulers.find(name);
423 if (it != mySchedulers.end())
424 func(it->second.get());
428 bool preEvaluation()
override;
429 bool tickEvaluation()
override;
432 bool canceled)
override;
441 static void onExit(
void*
data);
442 static void onPyExit();
443 static void* doTickThread(
void*
data);
445 void commitWorkItemInternal(
447 void addWorkItemDependencyInternal(
452 void addWorkItemResultsInternal(
460 void serializeWorkItem(
462 SerializationMap& serialization_map,
464 void serializeWorkItemCommit(
466 SerializationMap& serialization_map,
473 static ContextMap theContextMap;
475 static ObserverSet theObservers;
477 static bool theRegisteredAtExit;
488 mutable UT_Lock mySchedulersLock;
489 SchedulerMap mySchedulers;
492 PDG_ServiceScheduler* myServiceScheduler;
493 PDG_InProcessScheduler* myInProcessScheduler;
exint PDG_WorkItemID
Type defs for unique work item IDs.
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
const GLuint GLenum const void * binary
Class which writes ASCII or binary JSON streams.
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.
UT_SharedPtr< PDG_Scheduler > PDG_SchedulerPtr
Type def for registered type objects.
Class to store JSON objects as C++ objects.
PDG_Scheduler * defaultScheduler() const
const UT_StringHolder & name() const
The unique name of the graph context.