Skip to content

Commit

Permalink
#962 wip: TransferMsg -> MsgPtrThief
Browse files Browse the repository at this point in the history
- The new name should (hopefully) much more clearly represent
  what is occuring and/or should be expected.
  • Loading branch information
pnstickne committed Aug 14, 2020
1 parent 7ee0c10 commit 7b623c9
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 58 deletions.
58 changes: 19 additions & 39 deletions src/vt/messaging/active.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,26 +177,6 @@ struct BufferedActiveMsg {
{ }
};

/**
* \brief Used to transfer messages/lifetime into sendMsg.
*
* This type is not intented to be used directly.
* Instead, it supports implicit transforms which are used.
*/
template <typename MsgT>
struct TransferMsg {
// TODO: This should 'go away' when direct 'msg.get()' usages are replaced with 'msg'
// [[deprecated]]
/*implicit*/ TransferMsg(MsgT const* msgPtr) : msg_(promoteMsg<MsgT>(const_cast<MsgT*>(msgPtr))) {
}

// n.b. invalidates msg
/*implicit*/ TransferMsg(MsgPtr<MsgT>& msg) : msg_(std::move(msg)) {
}

MsgPtr<MsgT> msg_;
};

/**
* \struct ActiveMessenger active.h vt/messaging/active.h
*
Expand Down Expand Up @@ -479,7 +459,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
PendingSendType sendMsgSz(
NodeType dest,
HandlerType han,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
ByteType msg_size,
TagType tag = no_tag
);
Expand All @@ -498,7 +478,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
PendingSendType sendMsg(
NodeType dest,
HandlerType han,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag = no_tag
);

Expand All @@ -518,7 +498,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
PendingSendType sendMsgAuto(
NodeType dest,
HandlerType han,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag = no_tag
);

Expand Down Expand Up @@ -570,7 +550,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
*/
template <typename MsgT, ActiveTypedFnType<MsgT>* f>
PendingSendType broadcastMsgSz(
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
ByteType msg_size,
TagType tag = no_tag
);
Expand All @@ -585,7 +565,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
*/
template <typename MsgT, ActiveTypedFnType<MsgT>* f>
PendingSendType broadcastMsg(
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag = no_tag
);

Expand All @@ -601,7 +581,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
template <typename MsgT, ActiveTypedFnType<MsgT>* f>
PendingSendType sendMsg(
NodeType dest,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag = no_tag
);

Expand All @@ -622,7 +602,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
template <typename MsgT, ActiveTypedFnType<MsgT>* f>
PendingSendType sendMsgSz(
NodeType dest,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
ByteType msg_size,
TagType tag = no_tag
);
Expand All @@ -639,7 +619,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
*/
template <typename MsgT, ActiveTypedFnType<MsgT>* f>
PendingSendType broadcastMsgAuto(
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag = no_tag
);

Expand All @@ -657,7 +637,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
template <typename MsgT, ActiveTypedFnType<MsgT>* f>
PendingSendType sendMsgAuto(
NodeType dest,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag = no_tag
);

Expand Down Expand Up @@ -711,7 +691,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
*/
template <ActiveFnType* f, typename MsgT>
PendingSendType broadcastMsg(
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag = no_tag
);

Expand All @@ -727,7 +707,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
template <ActiveFnType* f, typename MsgT>
PendingSendType sendMsg(
NodeType dest,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag = no_tag
);

Expand Down Expand Up @@ -781,7 +761,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
typename MsgT = typename util::FunctorExtractor<FunctorT>::MessageType
>
PendingSendType broadcastMsg(
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag = no_tag
);

Expand All @@ -800,7 +780,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
typename MsgT = typename util::FunctorExtractor<FunctorT>::MessageType
>
PendingSendType broadcastMsgAuto(
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag = no_tag
);

Expand All @@ -819,7 +799,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
>
PendingSendType sendMsg(
NodeType dest,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag = no_tag
);

Expand All @@ -840,7 +820,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
>
PendingSendType sendMsgAuto(
NodeType dest,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag = no_tag
);

Expand Down Expand Up @@ -904,7 +884,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
template <typename MsgT>
PendingSendType broadcastMsg(
HandlerType han,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag = no_tag
);

Expand All @@ -922,7 +902,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
PendingSendType sendMsg(
NodeType dest,
HandlerType han,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
UserSendFnType send_payload_fn
);

Expand All @@ -938,7 +918,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
template <typename MsgT, ActiveTypedFnType<MsgT>* f>
PendingSendType sendMsg(
NodeType dest,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
UserSendFnType send_payload_fn
);

Expand All @@ -956,7 +936,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
template <typename MsgT>
PendingSendType broadcastMsgAuto(
HandlerType han,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag = no_tag
);

Expand Down
38 changes: 19 additions & 19 deletions src/vt/messaging/active.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ template <typename MsgT>
ActiveMessenger::PendingSendType ActiveMessenger::sendMsg(
NodeType dest,
HandlerType han,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag
) {
MsgSharedPtr<MsgT> msgptr = msg.msg_;
Expand All @@ -210,7 +210,7 @@ template <typename MsgT>
ActiveMessenger::PendingSendType ActiveMessenger::sendMsgSz(
NodeType dest,
HandlerType han,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
ByteType msg_size,
TagType tag
) {
Expand All @@ -222,7 +222,7 @@ template <typename MsgT>
ActiveMessenger::PendingSendType ActiveMessenger::sendMsgAuto(
NodeType dest,
HandlerType han,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag
) {
MsgSharedPtr<MsgT> msgptr = msg.msg_;
Expand All @@ -231,7 +231,7 @@ ActiveMessenger::PendingSendType ActiveMessenger::sendMsgAuto(

template <typename MsgT, ActiveTypedFnType<MsgT>* f>
ActiveMessenger::PendingSendType ActiveMessenger::broadcastMsgSz(
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
ByteType msg_size,
TagType tag
) {
Expand All @@ -244,7 +244,7 @@ ActiveMessenger::PendingSendType ActiveMessenger::broadcastMsgSz(

template <typename MsgT, ActiveTypedFnType<MsgT>* f>
ActiveMessenger::PendingSendType ActiveMessenger::broadcastMsg(
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag
) {
auto const han = auto_registry::makeAutoHandler<MsgT,f>();
Expand All @@ -257,7 +257,7 @@ ActiveMessenger::PendingSendType ActiveMessenger::broadcastMsg(
template <typename MsgT, ActiveTypedFnType<MsgT>* f>
ActiveMessenger::PendingSendType ActiveMessenger::sendMsg(
NodeType dest,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag
) {
auto const han = auto_registry::makeAutoHandler<MsgT,f>();
Expand All @@ -268,7 +268,7 @@ ActiveMessenger::PendingSendType ActiveMessenger::sendMsg(
template <typename MsgT, ActiveTypedFnType<MsgT>* f>
ActiveMessenger::PendingSendType ActiveMessenger::sendMsgSz(
NodeType dest,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
ByteType msg_size,
TagType tag
) {
Expand All @@ -280,7 +280,7 @@ ActiveMessenger::PendingSendType ActiveMessenger::sendMsgSz(
template <typename MsgT, ActiveTypedFnType<MsgT>* f>
ActiveMessenger::PendingSendType ActiveMessenger::sendMsgAuto(
NodeType dest,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag
) {
auto const han = auto_registry::makeAutoHandler<MsgT,f>();
Expand All @@ -290,7 +290,7 @@ ActiveMessenger::PendingSendType ActiveMessenger::sendMsgAuto(

template <typename MsgT, ActiveTypedFnType<MsgT>* f>
ActiveMessenger::PendingSendType ActiveMessenger::broadcastMsgAuto(
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag
) {
auto const han = auto_registry::makeAutoHandler<MsgT,f>();
Expand All @@ -302,7 +302,7 @@ ActiveMessenger::PendingSendType ActiveMessenger::broadcastMsgAuto(

template <ActiveFnType* f, typename MsgT>
ActiveMessenger::PendingSendType ActiveMessenger::broadcastMsg(
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag
) {
auto const han = auto_registry::makeAutoHandler<MsgT,f>();
Expand All @@ -315,7 +315,7 @@ ActiveMessenger::PendingSendType ActiveMessenger::broadcastMsg(
template <ActiveFnType* f, typename MsgT>
ActiveMessenger::PendingSendType ActiveMessenger::sendMsg(
NodeType dest,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag
) {
auto const han = auto_registry::makeAutoHandler<MsgT,f>();
Expand All @@ -325,7 +325,7 @@ ActiveMessenger::PendingSendType ActiveMessenger::sendMsg(

template <typename FunctorT, typename MsgT>
ActiveMessenger::PendingSendType ActiveMessenger::broadcastMsg(
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag
) {
auto const han = auto_registry::makeAutoHandlerFunctor<FunctorT,true,MsgT*>();
Expand All @@ -338,7 +338,7 @@ ActiveMessenger::PendingSendType ActiveMessenger::broadcastMsg(
template <typename FunctorT, typename MsgT>
ActiveMessenger::PendingSendType ActiveMessenger::sendMsg(
NodeType dest,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag
) {
auto const han = auto_registry::makeAutoHandlerFunctor<FunctorT,true,MsgT*>();
Expand All @@ -348,7 +348,7 @@ ActiveMessenger::PendingSendType ActiveMessenger::sendMsg(

template <typename FunctorT, typename MsgT>
ActiveMessenger::PendingSendType ActiveMessenger::broadcastMsgAuto(
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag
) {
auto const han = auto_registry::makeAutoHandlerFunctor<FunctorT,true,MsgT*>();
Expand All @@ -361,7 +361,7 @@ ActiveMessenger::PendingSendType ActiveMessenger::broadcastMsgAuto(
template <typename FunctorT, typename MsgT>
ActiveMessenger::PendingSendType ActiveMessenger::sendMsgAuto(
NodeType dest,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag
) {
auto const han = auto_registry::makeAutoHandlerFunctor<FunctorT,true,MsgT*>();
Expand All @@ -373,7 +373,7 @@ template <typename MsgT>
ActiveMessenger::PendingSendType ActiveMessenger::sendMsg(
NodeType dest,
HandlerType han,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
UserSendFnType send_payload_fn
) {
namespace ph = std::placeholders;
Expand All @@ -392,7 +392,7 @@ ActiveMessenger::PendingSendType ActiveMessenger::sendMsg(
template <typename MsgT, ActiveTypedFnType<MsgT>* f>
ActiveMessenger::PendingSendType ActiveMessenger::sendMsg(
NodeType dest,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
UserSendFnType send_payload_fn
) {
auto const han = auto_registry::makeAutoHandler<MsgT,f>();
Expand All @@ -402,7 +402,7 @@ ActiveMessenger::PendingSendType ActiveMessenger::sendMsg(
template <typename MsgT>
ActiveMessenger::PendingSendType ActiveMessenger::broadcastMsg(
HandlerType han,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag
) {
MsgSharedPtr<MsgT> msgptr = msg.msg_;
Expand All @@ -414,7 +414,7 @@ ActiveMessenger::PendingSendType ActiveMessenger::broadcastMsg(
template <typename MsgT>
ActiveMessenger::PendingSendType ActiveMessenger::broadcastMsgAuto(
HandlerType han,
TransferMsg<MsgT> msg,
MsgPtrThief<MsgT> msg,
TagType tag
) {
MsgSharedPtr<MsgT> msgptr = msg.msg_;
Expand Down
Loading

0 comments on commit 7b623c9

Please sign in to comment.