RejectedSoftware Forums

Sign up

Async system calls

Hi!

I was wondering, does vibe.d has a Fiber-aware alternative to execute functions family in std.process? It seems there were some functions in 0.7.17, but not in the current master.

Re: Async system calls

On Mon, 13 Jan 2014 18:28:44 GMT, Sergei Nosov wrote:

Hi!

I was wondering, does vibe.d has a Fiber-aware alternative to execute functions family in std.process? It seems there were some functions in 0.7.17, but not in the current master.

I didn't really find any, so I started using the following utility function, which returns status and stdout. Seems to work:

private Tuple!(int, string) waitLoop(ref ProcessPipes pipes, Duration timeout)
{
    auto startTime = Clock.currSystemTick();
    while (true)
    {
        auto p = tryWait(pipes.pid);
        if (p.terminated)
        {
            return tuple(p.status, pipes.stdout
                         .byLine(KeepTerminator.yes)
                         .reduce!((a, b) => a ~ b)
                         .idup);
        }
        else
        {
            auto elapsed = cast(Duration)(Clock.currSystemTick() - startTime);
            if (timeout == Duration.zero || elapsed < timeout)
                yield();
            else
                return tuple(-1, "");
        }
    }
    assert(0);
}

Re: Async system calls

Am 13.01.2014 19:28, schrieb Sergei Nosov:

Hi!

I was wondering, does vibe.d has a Fiber-aware alternative to execute functions family in std.process? It seems there were some functions in 0.7.17, but not in the current master.

I've uploaded a process class that I have lying around for a project:
https://gist.github.com/s-ludwig/8434299

It also requires this for handling stdout/stdin, if those are supposed
to be used as streams: https://gist.github.com/s-ludwig/5942882

Those will probably be included in vibe.d at some point, but I can't say
when yet.