Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using spawn in shared static this #371

Open
SerialVelocity opened this issue Nov 3, 2013 · 4 comments
Open

Using spawn in shared static this #371

SerialVelocity opened this issue Nov 3, 2013 · 4 comments

Comments

@SerialVelocity
Copy link

Hey,

When running the program attached, I get the output:

A
B

but when I use dub and enable vibe.d with or without VibeCustomMain, it hangs after only printing:

A

Any idea why?

import std.concurrency;
import std.stdio;

void main() {
}


static class A {
  shared static this() {
    stderr.writeln("A");
    spawn(&func);
  }

  static void func() {
    stderr.writeln("B");
  }
}
@SerialVelocity
Copy link
Author

Just found out it works with dub --rdmd
I'm using dmd 2.063.2

@s-ludwig
Copy link
Member

s-ludwig commented Nov 4, 2013

Interestingly, I was able to reproduce it the first time I tried. Then with an import vibe.d; it worked and then it also worked without the import for some reason. Even with a Thread.sleep(1.seconds); added before the "B" always both are printed now...

@SerialVelocity
Copy link
Author

Hmmm, it works for me if I add an import vibe.d but when I remove it, it ceases to work again. Any idea why that happens?

@s-ludwig
Copy link
Member

s-ludwig commented Nov 7, 2013

After some more trying it seems to be some kind of race condition. It "always" works for me right after the first "dub" invocation, but fails for the following invocations (with a cached build as done on latest DUB master, or when executing it manually), but not always. Currently I have no idea what causes this, or where the cause lies (vibe.d or Druntime/Phobos). I'll do some more testing when I get more time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants