Am 23.12.2013 00:49, schrieb Julian Wiesener:
Hi,

On Sun, 2013-12-22 at 23:41 +0100, Tommi Mäkitalo wrote:
I don't really see a good solution for that, other than keeping
everything as it is. Any ideas?
timeout() could return WeakTimespan<Timespan::Milliseconds>, instead:

template<typename Resolution = Timespan::Microseconds>
class WeakTimespan;

Add a operator int64_t that is specialised for each Resolution and allow
a Cast to Timespan. Still not perfect but would allow a transition to a
more typesafe interface.

unsigned timeoutMs = client.timeout(); //still works
cxxtools::Timespan timeout(client.timeout()); //would be correct no
matter what resolution client.timeout() returns.



Regards,
Julian
This is a good idea. I implemented it. The Timespan object got some modifications.

There is now a WeakTimespan<uint64_t> template, which has automatic conversion operators from and to number. The template argument specifies a factor, which must be used to get the microseconds, needed by Timespan. Typedefs for Microseconds, Milliseconds, Seconds, Minutes, Hours and Days are defined.

There are no getters yet, which use the new classes but the timed wait for condition and cxxtools::Thread::sleep which expects a cxxtools::Millisecond object. This can be constructed with just a number or with another Timestamp object. This makes it flexible and readable:

   cxxtools::Thread::sleep(500);   // sleeps 500 milliseconds
   cxxtools::Thread::sleep(Milliseconds(500));   // same as above
   cxxtools::Thread::sleep(Seconds(0.5));   // same as above

Since everything is inline, no extra cost is to be payed for that.

Tommi

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

Reply via email to