Thread overview
std.concurrency and module constructors
May 11, 2012
japplegame
May 11, 2012
japplegame
May 11, 2012
OS: Windows 7 64bit
Compiler: DMD32 D Compiler v2.059

Using spawn in module constructor causes very strange behavior.

import std.concurrency;
import std.stdio;
void main() {
}
void worker() {
  receiveOnly!OwnerTerminated;
}
static this() {
  writeln("module constructor");
  spawn(&worker);
}
static ~this() {
  writeln("module destructor");
}

prints in console:

module constructor
module destructor
module constructor
module destructor
module constructor
module constructor
module constructor
module constructor
module constructor
...
May 11, 2012
On Fri, 11 May 2012 07:34:46 -0400, japplegame <japplegame@gmail.com> wrote:

> OS: Windows 7 64bit
> Compiler: DMD32 D Compiler v2.059
>
> Using spawn in module constructor causes very strange behavior.
>
> import std.concurrency;
> import std.stdio;
> void main() {
> }
> void worker() {
>    receiveOnly!OwnerTerminated;
> }
> static this() {
>    writeln("module constructor");
>    spawn(&worker);
> }
> static ~this() {
>    writeln("module destructor");
> }
>
> prints in console:
>
> module constructor
> module destructor
> module constructor
> module destructor
> module constructor
> module constructor
> module constructor
> module constructor
> module constructor
> ...

This list is for bugzilla to post to, it is not for general bug reports or help requests.  I really wish it was disabled to post to from everyone but bugzilla.

Please repost your issue to D.learn.

Thanks

-Steve
May 11, 2012
Oh, I'm sorry. My mistake.