-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sequencer: #4: initial implementation of virtual context sequencing
- Loading branch information
1 parent
2c55ea2
commit b23abc1
Showing
24 changed files
with
902 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
#if ! defined __RUNTIME_TRANSPORT_SEQ_ACTION_VIRTUAL__ | ||
#define __RUNTIME_TRANSPORT_SEQ_ACTION_VIRTUAL__ | ||
|
||
#include "config.h" | ||
#include "seq_common.h" | ||
#include "termination.h" | ||
|
||
namespace vt { namespace seq { | ||
|
||
template <typename MessageT, typename VcT> | ||
struct ActionVirtual { | ||
using ActionType = std::function<void(MessageT*, VcT*)>; | ||
using CallableType = std::function<bool()>; | ||
|
||
SeqType const seq_id; | ||
ActionType const action; | ||
|
||
ActionVirtual(SeqType const& in_seq_id, ActionType const& in_action); | ||
|
||
void runAction(VcT* vc, MessageT* msg, bool const consume = true) const; | ||
CallableType generateCallable(MessageT* msg, VcT* vc) const; | ||
}; | ||
|
||
}} //end namespace vt::seq | ||
|
||
#include "seq_action_virtual.impl.h" | ||
|
||
#endif /* __RUNTIME_TRANSPORT_SEQ_ACTION_VIRTUAL__*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
#if ! defined __RUNTIME_TRANSPORT_SEQ_ACTION_VIRTUAL_IMPL__ | ||
#define __RUNTIME_TRANSPORT_SEQ_ACTION_VIRTUAL_IMPL__ | ||
|
||
#include "config.h" | ||
#include "seq_common.h" | ||
#include "seq_action.h" | ||
|
||
namespace vt { namespace seq { | ||
|
||
template <typename MessageT, typename VcT> | ||
ActionVirtual<MessageT, VcT>::ActionVirtual( | ||
SeqType const& in_seq_id, ActionType const& in_action | ||
) : seq_id(in_seq_id), action(in_action) | ||
{ } | ||
|
||
template <typename MessageT, typename VcT> | ||
void ActionVirtual<MessageT, VcT>::runAction( | ||
VcT* vc, MessageT* msg, bool consume | ||
) const { | ||
auto const callable = [this, consume, msg, vc]() -> bool { | ||
if (consume) { | ||
theTerm->consume(); | ||
} | ||
action(msg, vc); | ||
return false; | ||
}; | ||
|
||
contextualExecutionVirtual(seq_id, false, callable); | ||
} | ||
|
||
template <typename MessageT, typename VcT> | ||
typename ActionVirtual<MessageT, VcT>::CallableType | ||
ActionVirtual<MessageT, VcT>::generateCallable(MessageT* msg, VcT* vc) const { | ||
return [msg,vc,this](){ | ||
runAction(vc, msg); | ||
return false; | ||
}; | ||
} | ||
|
||
}} //end namespace vt::seq | ||
|
||
#endif /* __RUNTIME_TRANSPORT_SEQ_ACTION_VIRTUAL_IMPL__*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
|
||
#if ! defined __RUNTIME_TRANSPORT_SEQ_MATCHER_VIRTUAL__ | ||
#define __RUNTIME_TRANSPORT_SEQ_MATCHER_VIRTUAL__ | ||
|
||
#include "config.h" | ||
#include "registry_function.h" | ||
#include "message.h" | ||
#include "seq_common.h" | ||
#include "seq_action.h" | ||
#include "seq_state_virtual.h" | ||
#include "seq_action_virtual.h" | ||
|
||
#include <list> | ||
#include <unordered_map> | ||
|
||
namespace vt { namespace seq { | ||
|
||
template <typename VcT, typename MsgT, ActiveVCFunctionType<MsgT, VcT> *f> | ||
struct SeqMatcherVirtual { | ||
using SeqActionType = ActionVirtual<MsgT, VcT>; | ||
using MatchFuncType = ActiveVCFunctionType<MsgT, VcT>; | ||
using SeqMsgStateType = SeqMsgStateVirtual<VcT, MsgT, f>; | ||
|
||
template <typename T> | ||
using SeqStateContType = typename SeqMsgStateType::template ContainerType<T>; | ||
|
||
template <typename T> | ||
using SeqStateTaggedContType = typename SeqMsgStateType::template TagContainerType<T>; | ||
|
||
template <typename T> | ||
static bool hasFirstElem(T& lst); | ||
template <typename T> | ||
static auto getFirstElem(T& lst); | ||
|
||
template <typename T> | ||
static bool hasMatchingAnyNoTag(SeqStateContType<T>& lst); | ||
template <typename T> | ||
static auto getMatchingAnyNoTag(SeqStateContType<T>& lst); | ||
|
||
template <typename T> | ||
static bool hasMatchingAnyTagged( | ||
SeqStateTaggedContType<T>& tagged_lst, TagType const& tag | ||
); | ||
template <typename T> | ||
static auto getMatchingAnyTagged( | ||
SeqStateTaggedContType<T>& tagged_lst, TagType const& tag | ||
); | ||
|
||
static bool hasMatchingAction(TagType const& tag); | ||
static SeqActionType getMatchingAction(TagType const& tag); | ||
|
||
static bool hasMatchingMsg(TagType const& tag); | ||
static MsgT* getMatchingMsg(TagType const& tag); | ||
|
||
// Buffer messages and actions that do not match | ||
static void bufferUnmatchedMessage(MsgT* msg, TagType const& tag); | ||
template <typename FnT> | ||
static void bufferUnmatchedAction( | ||
FnT action, SeqType const& seq_id, TagType const& tag | ||
); | ||
}; | ||
|
||
}} //end namespace vt::seq | ||
|
||
#include "seq_matcher_virtual.impl.h" | ||
|
||
#endif /* __RUNTIME_TRANSPORT_SEQ_MATCHER_VIRTUAL__*/ |
Oops, something went wrong.