9 #ifndef __PDG_SCHEDULER_H__
10 #define __PDG_SCHEDULER_H__
53 class PDGN_PollingClientNNG;
188 {
return &myIsCookedDep; }
192 {
return &myIsSetupDep; }
211 virtual void onScheduleStatic(
218 virtual ScheduleResult onSchedule(
PDG_WorkItem* work_item) = 0;
221 virtual void onCancelWorkItems(
227 virtual bool onStart() = 0;
231 virtual bool onStop() = 0;
234 virtual bool onStartCook(
239 virtual bool onStopCook(
bool cancel) = 0;
243 virtual void onConfigureCook(
248 virtual bool onSetupCook() = 0;
251 virtual TickResult onTick() = 0;
255 virtual AcceptResult onAcceptWorkItem(
259 virtual bool onTransferFile(
288 bool check_type)
const;
299 bool check_type)
const;
339 void setAcceptInProcess(
bool in_process);
386 virtual bool endSharedServer(
389 virtual void clearSharedServerInfo(
402 virtual void cleanTempDirectory();
405 void stop(
bool exiting);
414 void cancelCook(
bool pause);
441 void onWorkItemPriorityChanged(
443 void process(
bool skip_ready_items);
445 bool isRunning(
int count=0);
449 bool isWaitForFailures()
const;
450 bool isValidateOutputFiles()
const;
451 bool isCheckExpectedOutputFiles()
const;
452 bool isCompressWorkItemData()
const;
453 virtual PDGN::PDGN_PollingClientNNG*
456 WorkItemDataSource workItemDataSource()
const;
458 int numRunningItems()
const;
459 int numFailedItems()
const;
460 int numQueuedItems()
const;
465 void dependencyGraph(
483 template <
typename T,
typename D=T>
490 const D& default_value,
499 parm_name.
format(
"{}_{}", prefix, parm);
509 if (work_item && work_item->
isBatch())
513 if (batch_item->batchSize() > 0)
514 eval_work_item = batch_item->batchItems()[0];
517 result = default_value;
521 if (!port->
evaluate(0, result, eval_work_item, errors))
533 port->
evaluate(0, toggle_result, eval_work_item, errors);
535 if (toggle_result < 1)
542 if (!port->
evaluate(0, result, eval_work_item, errors))
550 void onWorkItemSetStringArray(
555 void onWorkItemSetFloatArray(
560 void onWorkItemSetIntArray(
565 void onWorkItemSetFileArray(
570 void onWorkItemSetDictArray(
576 void onWorkItemSetPyObject(
581 void onWorkItemSetString(
587 void onWorkItemSetFloat(
593 void onWorkItemSetInt(
599 void onWorkItemSetFile(
605 void onWorkItemSetDict(
612 void onWorkItemAddOutput(
619 void onWorkItemAddOutputs(
626 void onWorkItemAddOutputs(
633 void onWorkItemInvalidateCache(
637 void onWorkItemSucceeded(
641 void onWorkItemFailed(
644 void onWorkItemCanceled(
647 void onWorkItemStartCook(
652 void onWorkItemSetCustomState(
656 void onWorkItemSetCookPercent(
660 void onWorkItemAppendLog(
680 bool skip_defaults)
const;
688 virtual fpreal tickPeriod()
const;
689 virtual int maxItemsPerTick()
const;
690 virtual int maxConcurrentTasks()
const;
716 using ResultQueue = UT_ConcurrentQueue<Result>;
718 using PriorityQueue =
721 using WorkItemSet = UT_ConcurrentSet<PDG_WorkItemID>;
722 using NodeSet = UT_ConcurrentSet<PDG_Node*>;
723 using SharedServerInfoMap =
724 UT_ConcurrentHashMap<UT_StringHolder, PDGT_ValueArgs>;
727 ScheduleResult schedule(
736 void updateDefaultDirectories();
742 PriorityQueue myScheduleQueue;
743 ResultQueue myScheduleResults;
744 ResultMap myPauseResults;
745 SharedServerInfoMap mySharedServerInfo;
748 WorkItemSet myRunningItems;
749 WorkItemSet myFailedItems;
750 WorkItemSet myLongRunningItems;
752 WorkItemSet myCanceledItems;
753 NodeSet myCanceledNodes;
767 WorkItemDataSource myDataSource;
768 TempDirCleanup myTempDirCleanup;
772 bool myCancelingFlag;
777 bool myIsWaitForFailures;
778 bool myIsValidateOutputFiles;
779 bool myIsCheckExpectedOutputFiles;
780 bool myIsCompressWorkItemData;
exint PDG_WorkItemID
Type defs for unique work item IDs.
The work item was cooked, and should be marked as succeeded.
GLuint GLsizei const GLchar * message
static const UT_StringHolder theTypeKey
The key for the type of the scheduler when writing it to JSON.
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.
PDGE_Dependency * isSetupDep()
Returns the is cooked dep for this scheduler.
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.
Class which writes ASCII or binary JSON streams.
**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.
static const UT_StringHolder theParametersKey
The key for the parameters of the scheduler when writing them to JSON.
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_WorkItemState
Enum of possible work item states.
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.
PDG_PathMappingMode
Enumeration of path mapping modes available on the scheduler.
GLuint const GLchar * name
virtual const PDG_NodeInterface * templateInterface() const
PDG_WorkItemLogType
Enumeration of work item log message types.
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.
Class to store JSON objects as C++ objects.
void pause(int delay) noexcept
#define UT_ConcurrentPriorityQueue
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.
static const UT_StringHolder theNameKey
The key for the name of the scheduler when writing it to JSON.
SYS_FORCE_INLINE bool isstring() const
virtual const PDG_EventFilter & supportedEventTypes() const =0
Returns the list of supported event types for this emitter.