Skip to content

Commit

Permalink
#1125: scheduler: extract common part for runInEpoch* functions
Browse files Browse the repository at this point in the history
  • Loading branch information
cz4rs committed Nov 3, 2020
1 parent a124269 commit 04e0a8d
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/vt/scheduler/scheduler.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@
namespace vt {

template <typename Callable>
void runInEpochCollective(Callable&& fn) {
void runInEpoch(EpochType ep, Callable&& fn) {
theSched()->triggerEvent(sched::SchedulerEvent::PendingSchedulerLoop);

auto ep = theTerm()->makeEpochCollective();
theMsg()->pushEpoch(ep);
fn();
theMsg()->popEpoch(ep);
Expand All @@ -64,15 +63,15 @@ void runInEpochCollective(Callable&& fn) {
}

template <typename Callable>
void runInEpochRooted(Callable&& fn) {
theSched()->triggerEvent(sched::SchedulerEvent::PendingSchedulerLoop);
void runInEpochCollective(Callable&& fn) {
auto ep = theTerm()->makeEpochCollective();
runInEpoch(ep, std::forward<Callable>(fn));
}

template <typename Callable>
void runInEpochRooted(Callable&& fn) {
auto ep = theTerm()->makeEpochRooted();
theMsg()->pushEpoch(ep);
fn();
theMsg()->popEpoch(ep);
theTerm()->finishedEpoch(ep);
runSchedulerThrough(ep);
runInEpoch(ep, std::forward<Callable>(fn));
}

} /* end namespace vt */
Expand Down

0 comments on commit 04e0a8d

Please sign in to comment.