Initial commit
This commit is contained in:
Executable
+66
@@ -0,0 +1,66 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/types/LwdTypes.h>
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
#include <memory>
|
||||
#include <condition_variable>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
|
||||
//Forward declarations
|
||||
namespace wfs {
|
||||
class Workflow;
|
||||
class ActivityInstance;
|
||||
}
|
||||
namespace wep {
|
||||
class WorkflowExecutionPlan;
|
||||
}
|
||||
namespace scheduling {
|
||||
class AbstractScheduler;
|
||||
}
|
||||
|
||||
// Main namespace
|
||||
namespace enactment {
|
||||
|
||||
|
||||
class EnactmentEngine {
|
||||
|
||||
// Mutable properties that need to be accessed via getter-/setter-functions.
|
||||
private:
|
||||
std::shared_ptr<wep::WorkflowExecutionPlan> wep;
|
||||
|
||||
bool breakExecutionLoop = false;
|
||||
|
||||
std::queue<wfs::ActivityInstance*> updateQueue;
|
||||
std::mutex updateMutex;
|
||||
std::condition_variable updateCondition;
|
||||
|
||||
bool enableWepDotFileWriter;
|
||||
bool enableEarlyEvaluation;
|
||||
|
||||
// Invariant properties that can be accessed directly.
|
||||
public:
|
||||
wfs::Workflow& workflow;
|
||||
scheduling::AbstractScheduler& scheduler;
|
||||
|
||||
// Public static functions
|
||||
public:
|
||||
static void init(int argc, char** argv);
|
||||
static void finish();
|
||||
|
||||
// Public functions
|
||||
public:
|
||||
EnactmentEngine(wfs::Workflow& workflow, scheduling::AbstractScheduler& scheduler) noexcept;
|
||||
|
||||
void workflowExecutionLoop(lwd::_wfr_lwd* input, lwd::_wfr_lwd* output);
|
||||
|
||||
void notifyActivityInstanceStateUpdate(wfs::ActivityInstance& ai, scheduling::AbstractScheduler& scheduler);
|
||||
};
|
||||
|
||||
} /* namespace wep */
|
||||
} /* namespace wfr */
|
||||
|
||||
|
||||
Executable
+85
@@ -0,0 +1,85 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/types/LwdTypes.h>
|
||||
#include <stack>
|
||||
#include <map>
|
||||
#include <utility>
|
||||
#include <queue>
|
||||
#include <set>
|
||||
#include <memory>
|
||||
|
||||
|
||||
// Forward declarations
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
class Workflow;
|
||||
class ActivityInstance;
|
||||
class CompositeActivityInstance;
|
||||
class Activity;
|
||||
}
|
||||
namespace wep {
|
||||
class WorkflowExecutionPlan;
|
||||
class AbstractWepNode;
|
||||
class AtomicWepNode;
|
||||
class AssignWepNode;
|
||||
class CompositeStartWepNode;
|
||||
class CompositeEndWepNode;
|
||||
class IterationStartWepNode;
|
||||
class IterationEndWepNode;
|
||||
}
|
||||
|
||||
|
||||
// Main namespace
|
||||
namespace enactment {
|
||||
|
||||
|
||||
class WepBuilder {
|
||||
|
||||
// Mutable properties that need to be accessed via getter-/setter-functions.
|
||||
private:
|
||||
std::shared_ptr<wep::WorkflowExecutionPlan> wep;
|
||||
|
||||
typedef std::map<wfs::Activity*, wfr::wfs::ActivityInstance*> activityInstanceMap_t;
|
||||
typedef std::map<wfs::ActivityInstance*, std::pair<wep::AbstractWepNode*, wep::AbstractWepNode*>> wepNodeMap_t;
|
||||
|
||||
std::stack<wfs::ActivityInstance*> parentStack;
|
||||
std::stack<std::pair<wep::AbstractWepNode*, wep::AbstractWepNode*>> parentWepStack;
|
||||
std::stack<wfr_id_t> iterationIdStack;
|
||||
wepNodeMap_t wepNodeMap;
|
||||
|
||||
std::vector<wep::AtomicWepNode*> readyToExecuteAtomicNodes;
|
||||
std::vector<wep::AssignWepNode*> readyToExecuteAssignNodes;
|
||||
|
||||
wfr_size_t wepNodeCount = 0;
|
||||
wfr_size_t wepVisitationCount = 0;
|
||||
|
||||
bool earlyEvaluationMode;
|
||||
|
||||
// Non-public functions
|
||||
private:
|
||||
wepNodeMap_t::mapped_type createWEPnode(wfs::Activity& a, wfs::ActivityInstance& ai, wepNodeMap_t& wepNodeMap);
|
||||
|
||||
void visitActivity(wfs::Activity& element, activityInstanceMap_t& instanceMap, wepNodeMap_t& wepNodeMap);
|
||||
|
||||
wepNodeMap_t::mapped_type createIterationWepNodes(wfr::wfs::ActivityInstance& ai, wepNodeMap_t::mapped_type& parent, wfr_id_t iterationID);
|
||||
|
||||
void handleChildren(wfs::CompositeActivityInstance& composite, wepNodeMap_t::mapped_type& parent, wepNodeMap_t::mapped_type* prevIter = nullptr);
|
||||
|
||||
// Public functions
|
||||
public:
|
||||
WepBuilder(bool earlyEvaluation) : earlyEvaluationMode(earlyEvaluation) {}
|
||||
virtual ~WepBuilder();
|
||||
|
||||
std::shared_ptr<wep::WorkflowExecutionPlan> createWEP(wfs::Workflow& wf, lwd::_wfr_lwd* input, lwd::_wfr_lwd* output);
|
||||
|
||||
bool updateExecutionPlan(std::queue<wfs::ActivityInstance*>& updateInstances);
|
||||
|
||||
const std::vector<wep::AtomicWepNode*>& getReadyToExecuteAtomicNodes() { return readyToExecuteAtomicNodes; }
|
||||
|
||||
const std::vector<wep::AssignWepNode*>& getReadyToExecuteAssignNodes() { return readyToExecuteAssignNodes; }
|
||||
};
|
||||
|
||||
} /* namespace enactment */
|
||||
} /* namespace wfr */
|
||||
|
||||
Reference in New Issue
Block a user