I stuck at this and can't figure out the reason why the value of the variable ds is 0 when I do this: startTime = MonoTime.currTime; if I remove that statement, the value of ds isn't zeroed, it has the actual number of seconds. But I can't figure out, ds is of integer type and such, it is copied, right? or is this related to the fact I'm setting it withi a callback function?

here's the piece of code:
import std.net.curl;
auto http = HTTP(url);
http.method = HTTP.Method.get;
...
the relevant part:

        http.onProgress = (size_t dltotal, size_t dlnow,
                           size_t ultotal, size_t ulnow) {
            if(dlNow > 0) {
                MonoTime endTime = MonoTime.currTime;
                Duration duration = endTime - startTime;
                long ds = duration.total!"seconds";
                writeln("duration!seconds  = ", ds);
                startTime = MonoTime.currTime;

if I put startTime = MonoTime.currTime, ds is zero, otherwise, if I remove it, ds has the actual value.

startTime is first set right before http.perform() call:

        startTime = MonoTime.currTime;
        http.perform();

(My goal is define the download transfer rate, different approachs for this are welcome)

Reply via email to