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(
297 bool check_type)
const;
308 bool check_type)
const;
348 void setAcceptInProcess(
bool in_process);
395 virtual bool endSharedServer(
398 virtual void clearSharedServerInfo(
411 virtual void cleanTempDirectory();
414 void stop(
bool exiting);
423 void cancelCook(
bool pause);
450 void onWorkItemPriorityChanged(
452 void process(
bool skip_ready_items);
454 bool isRunning(
int count=0);
458 bool isWaitForFailures()
const;
459 bool isValidateOutputFiles()
const;
460 bool isCheckExpectedOutputFiles()
const;
461 bool isCompressWorkItemData()
const;
462 virtual PDGN::PDGN_PollingClientNNG*
465 WorkItemDataSource workItemDataSource()
const;
467 int numRunningItems()
const;
468 int numFailedItems()
const;
469 int numQueuedItems()
const;
474 void dependencyGraph(
492 template <
typename T,
typename D=T>
499 const D& default_value,
508 parm_name.
format(
"{}_{}", prefix, parm);
518 if (work_item && work_item->
isBatch())
522 if (batch_item->batchSize() > 0)
523 eval_work_item = batch_item->batchItems()[0];
526 result = default_value;
530 if (!port->
evaluate(0, result, eval_work_item, errors))
542 port->
evaluate(0, toggle_result, eval_work_item, errors);
544 if (toggle_result < 1)
551 if (!port->
evaluate(0, result, eval_work_item, errors))
559 void onWorkItemSetStringArray(
564 void onWorkItemSetFloatArray(
569 void onWorkItemSetIntArray(
574 void onWorkItemSetFileArray(
579 void onWorkItemSetDictArray(
585 void onWorkItemSetPyObject(
590 void onWorkItemSetString(
596 void onWorkItemSetFloat(
602 void onWorkItemSetInt(
608 void onWorkItemSetFile(
614 void onWorkItemSetDict(
621 void onWorkItemAddOutput(
628 void onWorkItemAddOutputs(
635 void onWorkItemAddOutputs(
642 void onWorkItemInvalidateCache(
646 void onWorkItemSucceeded(
650 void onWorkItemFailed(
653 void onWorkItemCanceled(
656 void onWorkItemStartCook(
661 void onWorkItemSetCustomState(
665 void onWorkItemSetCookPercent(
669 void onWorkItemAppendLog(
689 bool skip_defaults)
const;
697 virtual fpreal tickPeriod()
const;
698 virtual int maxItemsPerTick()
const;
699 virtual int maxConcurrentTasks()
const;
728 using ResultQueue = UT_ConcurrentQueue<Result>;
730 using PriorityQueue =
735 using SharedServerInfoMap =
739 ScheduleResult schedule(
748 void updateDefaultDirectories();
754 PriorityQueue myScheduleQueue;
755 ResultQueue myScheduleResults;
756 ResultMap myPauseResults;
757 SharedServerInfoMap mySharedServerInfo;
760 WorkItemSet myRunningItems;
761 WorkItemSet myFailedItems;
762 WorkItemSet myLongRunningItems;
764 WorkItemSet myCanceledItems;
765 NodeSet myCanceledNodes;
779 WorkItemDataSource myDataSource;
780 TempDirCleanup myTempDirCleanup;
784 bool myCancelingFlag;
789 bool myIsWaitForFailures;
790 bool myIsValidateOutputFiles;
791 bool myIsCheckExpectedOutputFiles;
792 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.
GLsizei const GLfloat * value
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()
GLint GLint GLsizei GLint GLenum GLenum type
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.
tbb::concurrent_hash_map< K, T, H, A > UT_ConcurrentHashMap
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
bool process(T &func, UT_WorkBuffer &fullpath, exint fullpath_len, const UT_StringArray &paths, const UT_Array< FS_Stat > &stats)
Utility function to process the contents of the traverse() function.
#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.
tbb::concurrent_unordered_set< K, H, P, A > UT_ConcurrentSet
SYS_FORCE_INLINE bool isstring() const
virtual const PDG_EventFilter & supportedEventTypes() const =0
Returns the list of supported event types for this emitter.