fork/waitpid and std.concurrency.spawn

Puming via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 23 00:59:00 PDT 2014


OK, I see your point. I didn't know much about windows, so didn't 
know that fork in windows was so different from posix. This looks 
reasonable.

What I really want is a actor modal similar to std.concurrency, 
with a similar API and spawn/send/replay semantics, but using 
processes instead of threads.

Actually, generalize this further to fibers and cross machine 
process, it would be a full blown actor system just like Akka.


On Tuesday, 22 July 2014 at 16:11:31 UTC, FreeSlave wrote:
> On Tuesday, 22 July 2014 at 14:26:05 UTC, Puming wrote:
>> I've only found spawnProcess/spawnShell and the like, which 
>> executes a new command, but not a function pointer, like 
>> fork() and std.concurrency.spawn does.
>>
>> What is the function that does what I describe?
>>
>> On Tuesday, 22 July 2014 at 10:43:58 UTC, FreeSlave wrote:
>>> On Tuesday, 22 July 2014 at 07:58:50 UTC, Puming wrote:
>>>> Is there a fork()/wait() API similar to std.concurrency 
>>>> spawn()?
>>>>
>>>> The best thing I've got so far is module 
>>>> core.sys.posix.unistd.fork(), but it seems to only work in 
>>>> posix. Is there a unified API for process level concurrency? 
>>>> ideally with actor and send message support too.
>>>
>>> You need std.process.
>
> I'm not sure what you're trying to do. Posix fork does not just 
> spawn function, it spawns new process as copy of its parent and 
> continue execution from the point where fork returns.
> Windows creates processes in some different way, and it seems 
> there is no function with same functionality as Posix fork in 
> WinAPI (by the way you can try to find some implementations on 
> the Internet / use Cygwin / try to use Microsoft Posix 
> Subsystem).
> I think the reason why phobos does not have functionality you 
> want is that standard library should be platform-agnostic. So 
> instead of emulating things which are not supported by some 
> platform, it just truncates them.



More information about the Digitalmars-d-learn mailing list