@@ -28,15 +28,26 @@ auto Tag::from_logical_time(const LogicalTime& logical_time) noexcept -> Tag {
2828 return {logical_time.time_point (), logical_time.micro_step ()};
2929}
3030
31- auto Tag::max_for_timepoint (TimePoint time_point) noexcept -> Tag {
32- return {time_point, std::numeric_limits<mstep_t >::max ()};
31+ auto Tag::delay (Duration offset) const noexcept -> Tag {
32+ if (offset == Duration::zero ()) {
33+ validate (this ->micro_step_ != std::numeric_limits<mstep_t >::max (), " Microstep overflow detected!" );
34+ return {this ->time_point_ , this ->micro_step_ + 1 };
35+ }
36+ return {this ->time_point_ + offset, 0 };
3337}
3438
35- auto Tag::delay (Duration offset) const noexcept -> Tag {
39+ auto Tag::subtract (Duration offset) const noexcept -> Tag {
3640 if (offset == Duration::zero ()) {
37- return Tag{this ->time_point_ , this ->micro_step_ + 1 };
41+ return decrement ();
42+ }
43+ return {time_point_ - offset, std::numeric_limits<mstep_t >::max ()};
44+ }
45+
46+ auto Tag::decrement () const noexcept -> Tag {
47+ if (micro_step_ == 0 ) {
48+ return {time_point_ - Duration{1 }, std::numeric_limits<mstep_t >::max ()};
3849 }
39- return Tag{ this -> time_point_ + offset, 0 };
50+ return { time_point_, micro_step_ - 1 };
4051}
4152
4253void LogicalTime::advance_to (const Tag& tag) {
@@ -46,7 +57,7 @@ void LogicalTime::advance_to(const Tag& tag) {
4657}
4758
4859void LogicalTime::advance_to (const LogicalTime& time) {
49- reactor_assert (*this <= Tag::from_logical_time (time));
60+ reactor_assert (*this < Tag::from_logical_time (time));
5061 time_point_ = time.time_point ();
5162 micro_step_ = time.micro_step ();
5263}
0 commit comments