Duration.toTimeVal ? (following deprecation from 2.066)
Jonathan M Davis via Digitalmars-d
digitalmars-d at puremagic.com
Sun Aug 10 20:40:45 PDT 2014
On Monday, 11 August 2014 at 02:46:11 UTC, Timothee Cour via
Digitalmars-d wrote:
> On Sun, Aug 10, 2014 at 7:21 PM, Timothee Cour
> <thelastmammoth at gmail.com>
> wrote:
>
>> This used to work prior to 2.066 (rc):
>> Duration t;
>> auto tv=timeval(t.total!"seconds",t.fracSec.usecs);
>> now it works but with:
>> Deprecation: function core.time.Duration.fracSec is deprecated
>> - Please
>> use split instead.
>>
>> I see there's a SysTime.toTimeVal but there's no
>> Duration.toTimeVal.
>> Shouldn't there be?
>> What would be the new recommended implementation?
>> Also, I think deprecation messages could be more precise,
>> telling exactly
>> how to make the change instead of telling you the function
>> name.
>>
>>
> is this correct?
> int secs,usecs;
> timeout.split!("seconds","usecs")(secs,usecs);
> auto tv=timeval(secs,usecs);
> specifically, I'm not sure about the type 'int'.
Technically, timeval is
struct timeval
{
time_t tv_sec;
suseconds_t tv_usec;
}
so tv_sec is 64-bits on a 64-bit system, though you'd probably
get away with using an int. Regardless, I'd suggest doing this:
timeval tv;
timeout.split!("seconds, "usecs")(tv.tv_sec, tv.tv_usec);
since then you don't have to care what integral type they are.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list