9 #ifndef __PDG_SCHEDULER_H__
10 #define __PDG_SCHEDULER_H__
43 class PDGN_PollingClientNNG;
181 {
return &myIsCookedDep; }
196 virtual void onScheduleStatic(
203 virtual ScheduleResult onSchedule(
PDG_WorkItem* work_item) = 0;
206 virtual void onCancelWorkItems(
212 virtual bool onStart() = 0;
216 virtual bool onStop() = 0;
219 virtual bool onStartCook(
224 virtual bool onStopCook(
bool cancel) = 0;
231 virtual TickResult onTick() = 0;
235 virtual AcceptResult onAcceptWorkItem(
292 void setAcceptInProcess(
bool in_process);
337 virtual bool endSharedServer(
340 virtual void clearSharedServerInfo(
353 virtual void cleanTempDirectory();
356 void stop(
bool exiting);
359 void cancelCook(
bool pause);
371 void onWorkItemPriorityChanged(
PDG_WorkItem* work_item);
372 void process(
bool skip_ready_items);
374 bool isRunning(
int count=0);
378 bool isWaitForFailures()
const;
379 bool isValidateOutputFiles()
const;
380 bool isCheckExpectedOutputFiles()
const;
381 bool isCompressWorkItemData()
const;
382 virtual PDGN::PDGN_PollingClientNNG*
385 WorkItemDataSource workItemDataSource()
const;
387 int numRunningItems()
const;
388 int numFailedItems()
const;
389 int numQueuedItems()
const;
394 void dependencyGraph(
414 template <
typename T,
typename D=T>
420 const D& default_value,
429 parm_name.
format(
"{}_{}", prefix, parm);
439 if (work_item && work_item->
isBatch())
443 if (batch_item->batchSize() > 0)
444 eval_work_item = batch_item->batchItems()[0];
447 result = default_value;
451 if (!port->
evaluate(0, result, eval_work_item, errors))
463 port->
evaluate(0, toggle_result, eval_work_item, errors);
465 if (toggle_result < 1)
472 if (!port->
evaluate(0, result, eval_work_item, errors))
480 void onWorkItemSetStringArray(
485 void onWorkItemSetFloatArray(
490 void onWorkItemSetIntArray(
495 void onWorkItemSetFileArray(
501 void onWorkItemSetPyObject(
506 void onWorkItemSetString(
512 void onWorkItemSetFloat(
518 void onWorkItemSetInt(
524 void onWorkItemSetFile(
531 void onWorkItemAddOutput(
538 void onWorkItemAddOutputs(
545 void onWorkItemAddOutputs(
552 void onWorkItemInvalidateCache(
556 void onWorkItemSucceeded(
560 void onWorkItemFailed(
563 void onWorkItemCanceled(
566 void onWorkItemStartCook(
571 void onWorkItemSetCustomState(
575 void onWorkItemSetCookPercent(
579 void onWorkItemAppendLog(
595 virtual fpreal tickPeriod()
const;
596 virtual int maxItemsPerTick()
const;
597 virtual int maxConcurrentTasks()
const;
599 PathMappingMode mapMode()
const;
623 using ResultQueue = UT_ConcurrentQueue<Result>;
625 using PriorityQueue =
628 using WorkItemSet = UT_ConcurrentSet<PDG_WorkItemID>;
629 using NodeSet = UT_ConcurrentSet<PDG_Node*>;
630 using SharedServerInfoMap =
631 UT_ConcurrentHashMap<UT_StringHolder, PDGT_ValueArgs>;
641 void updateDefaultDirectories();
646 PriorityQueue myScheduleQueue;
647 ResultQueue myScheduleResults;
648 ResultMap myPauseResults;
649 SharedServerInfoMap mySharedServerInfo;
652 WorkItemSet myRunningItems;
653 WorkItemSet myFailedItems;
654 WorkItemSet myLongRunningItems;
656 WorkItemSet myCanceledItems;
657 NodeSet myCanceledNodes;
670 WorkItemDataSource myDataSource;
671 TempDirCleanup myTempDirCleanup;
675 bool myCancelingFlag;
680 bool myIsWaitForFailures;
681 bool myIsValidateOutputFiles;
682 bool myIsCheckExpectedOutputFiles;
683 bool myIsCompressWorkItemData;
The work item was cooked, and should be marked as succeeded.
GLuint GLsizei const GLchar * message
const UT_StringHolder & name() const
Returns the name of the shceudler.
virtual bool startService(UT_WorkBuffer &errors, PDG_Service *service)
Starts a service using this scheduler.
The scheduler is able to handle the specified work item.
Use the default, global path mapping.
Comparator< PriorityComparator, Reverse > Priority
Functor that compares two work item references or pointers by priority.
GLsizei const GLchar *const * path
The scheduler is not able to handle the specified work item.
SYS_FORCE_INLINE const char * buffer() const
The call to schedule the work item succeeded.
The temp file dir is not cleaned up automatically.
The work item was cooked, and should be marked as failed.
**But if you need a result
bool evaluateOverride(T &result, PDG_NodeInterface *node, const UT_StringHolder &prefix, const UT_StringHolder &parm, PDG_WorkItem *work_item, const D &default_value, UT_WorkBuffer &errors) const
virtual void addWarning(const UT_StringHolder &message) const
Adds a warning to the node interface – implemented in subclasses.
virtual bool reloadInstance(UT_WorkBuffer &errors)
The call to schedule the work item failed.
virtual PDGN::PDGN_PollingClientNNG * getPollingClient()
int64 Hash
The file hash/modtime type.
The work item was cooked, and should be marked as canceled.
bool isBatch() const
Returns true if the work tiem is a batch.
PDG_WorkItemLogType
Enumeration of work item log message types.
const UT_StringHolder & templateName() const
virtual void addError(const UT_StringHolder &message) const
Adds an error to the node interface – implemented in subclasses.
virtual int64 getMemoryUsage(bool inclusive) const
Returns the memory usage of this owner instance.
GLuint const GLchar * name
virtual Filter & supportedEventTypes() const =0
Returns the list of supported event types for this emitter.
PDG_WorkItemState
Enum of possible work item states.
size_t format(const char *fmt, const Args &...args)
TransferType
Enumeration of file transfer destination paths.
PDG_Port * parameter(const UT_StringHolder &name, int multi=-1) const
virtual bool stopService(UT_WorkBuffer &errors, PDG_Service *service)
Stops a service that was started with this scheduler.
The scheduler cannot handle the work item at this time.
The scheduler is busy, and cannot process additional work items.
SYS_FORCE_INLINE void append(char character)
UT_StringHolder debugName() const override
Debug name method, required by PDGE_DependencyOwner.
The scheduler is ready to accept work items.
virtual PDGE_Dependency::State evalResolve(PDGE_Resolutions &, const PDGE_Evaluator &, PDGE_Dependency *)
Called when a dependency owned by this object is resolved.
void pause(int delay) noexcept
#define UT_ConcurrentPriorityQueue
exint PDG_WorkItemID
Type defs for unique work item IDs.
bool evaluate(int index, fpreal &result, const PDG_WorkItem *work_item, UT_WorkBuffer &errors) const
PDGE_Dependency * isCookedDep()
Returns the is cooked dep for this scheduler.
virtual void resetOwner()
Resets the owner.
SYS_FORCE_INLINE bool isstring() const