Add millisecond accessor to Genode::Duration value object

Add a 'trunc_to_plain_ms' method to Gende::Duration to make
millisecond-accurate timing safer and more convenient.

Ref #2335
This commit is contained in:
Emery Hemingway 2017-11-01 12:44:27 -05:00 committed by Christian Helmuth
parent d4a75ed9bb
commit ed89f2f7f0
3 changed files with 8 additions and 0 deletions

View File

@ -359,6 +359,7 @@ _ZNK6Genode5Child21notify_resource_availEv T
_ZNK6Genode6Thread10stack_baseEv T
_ZNK6Genode6Thread4nameEv T
_ZNK6Genode6Thread9stack_topEv T
_ZNK6Genode8Duration17trunc_to_plain_msEv T
_ZNK6Genode8Duration17trunc_to_plain_usEv T
_ZNK6Genode8Duration9less_thanERS0_ T
_ZNKSt13bad_exception4whatEv T

View File

@ -80,6 +80,7 @@ struct Genode::Duration
explicit Duration(Microseconds us) { add(us); }
Microseconds trunc_to_plain_us() const;
Milliseconds trunc_to_plain_ms() const;
};
#endif /* _OS__DURATION_H_ */

View File

@ -82,3 +82,9 @@ Microseconds Duration::trunc_to_plain_us() const
{
return Microseconds(_microseconds + (_hours ? _hours * US_PER_HOUR : 0));
}
Milliseconds Duration::trunc_to_plain_ms() const
{
return Milliseconds(trunc_to_plain_us().value / 1000);
}