Skip to content

Commit

Permalink
allowed user to specify TIMEOUT status
Browse files Browse the repository at this point in the history
  • Loading branch information
godsme committed Mar 5, 2021
1 parent 1b8a53e commit 0dfd1e5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions include/trans-dsl/sched/action/SchedTimeGuard.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ struct SchedTimeGuard : SchedAction {
State state = State::INIT;
bool externalForceStopped = false;

private:
ABSTRACT(getTimeoutResult() const -> Status);
private:
USE_ROLE(RelativeTimer);
USE_ROLE(SchedAction);
Expand Down
8 changes: 4 additions & 4 deletions include/trans-dsl/sched/helper/TimeGuardHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TSL_NS_BEGIN

namespace details {

template<TimerId V_TIMER_ID, typename T_ACTION>
template<TimerId V_TIMER_ID, typename T_ACTION, Status TIMEOUT_RESULT = Result::TIMEOUT>
struct TimeGuard final {
template<TransListenerObservedAids const& AIDs>
class ActionRealType : public SchedTimeGuard {
Expand All @@ -28,14 +28,14 @@ namespace details {

Action action;
PlatformSpecifiedTimer timer{V_TIMER_ID};

OVERRIDE(getTimeoutResult() const -> Status) { return TIMEOUT_RESULT; }
public:
using ThreadActionCreator = ThreadCreator_t<Action>;
};
};

template<TimerId V_TIMER_ID, typename T_ACTION>
using TimeGuard_t = typename TimeGuard<V_TIMER_ID, T_ACTION>::template ActionRealType<EmptyAids>;
template<TimerId V_TIMER_ID, typename T_ACTION, Status TIMEOUT_RESULT = Result::TIMEOUT>
using TimeGuard_t = typename TimeGuard<V_TIMER_ID, T_ACTION, TIMEOUT_RESULT>::template ActionRealType<EmptyAids>;
}

TSL_NS_END
Expand Down
4 changes: 2 additions & 2 deletions src/sched/action/SchedTimeGuard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ auto SchedTimeGuard::handleEventTimeout(TransactionContext& context, Event const
}

if(status == Result::SUCCESS || (status == Result::FORCE_STOPPED && !externalForceStopped)) {
status = Result::TIMEOUT;
status = getTimeoutResult();
}

state = State::DONE;
Expand Down Expand Up @@ -143,7 +143,7 @@ auto SchedTimeGuard::onTimeout(TransactionContext& context) -> Status {
status = stop_(context, Result::TIMEOUT);
likely_branch
if(status == Result::SUCCESS || status == Result::FORCE_STOPPED) {
return Result::TIMEOUT;
return getTimeoutResult();
}
}

Expand Down

0 comments on commit 0dfd1e5

Please sign in to comment.