The OpenD Programming Language

StopWatch.this

Constructs a StopWatch. Whether it starts immediately depends on the AutoStart argument.

If StopWatch.init is used, then the constructed StopWatch isn't running (and can't be, since no constructor ran).

struct StopWatch
@safe nothrow @nogc
this

Examples

import core.thread : Thread;

{
    auto sw = StopWatch(AutoStart.yes);
    assert(sw.running);
    Thread.sleep(usecs(1));
    assert(sw.peek() > Duration.zero);
}
{
    auto sw = StopWatch(AutoStart.no);
    assert(!sw.running);
    Thread.sleep(usecs(1));
    assert(sw.peek() == Duration.zero);
}
{
    StopWatch sw;
    assert(!sw.running);
    Thread.sleep(usecs(1));
    assert(sw.peek() == Duration.zero);
}

assert(StopWatch.init == StopWatch(AutoStart.no));
assert(StopWatch.init != StopWatch(AutoStart.yes));

Meta