Re: How to kill whole application if child thread raises an exception?

2016-10-27 Thread dm via Digitalmars-d-learn
On Thursday, 27 October 2016 at 13:37:29 UTC, Steven Schveighoffer wrote: Hm... what about: import std.traits: Parameters; auto mySpawn(F)(F func, Parameters!F params) { static auto callIt(F func, Parameters!F params) { try { return func(params); }

Re: How to kill whole application if child thread raises an exception?

2016-10-27 Thread dm via Digitalmars-d-learn
I found http://arsdnet.net/this-week-in-d/2016-aug-07.html Maybe it's helps me.

Re: How to kill whole application if child thread raises an exception?

2016-10-27 Thread dm via Digitalmars-d-learn
On Friday, 28 October 2016 at 03:38:05 UTC, dm wrote: On Thursday, 27 October 2016 at 13:37:29 UTC, Steven Schveighoffer wrote: Hm... what about: ... Main thread still running. Actually it's depends on compiler. With ldc2 main thread doesn't stop, but with dmd seems all ok: root@proxytest:~#

Re: How to kill whole application if child thread raises an exception?

2016-10-27 Thread dm via Digitalmars-d-learn
On Thursday, 27 October 2016 at 13:37:29 UTC, Steven Schveighoffer wrote: Hm... what about: ... Main thread still running.

Re: How to kill whole application if child thread raises an exception?

2016-10-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/26/16 4:42 AM, dm wrote: Hi. I tried code below: import std.concurrency; import std.stdio; void func() { throw new Exception("I'm an exception"); } void main() { auto tID = spawn(&func); foreach(line; stdin.byLine) send(tID, ""); } I expect my application will die im

How to kill whole application if child thread raises an exception?

2016-10-26 Thread dm via Digitalmars-d-learn
Thanks all. I gues I must rewrote my app to send exeptions to other threads, use non blocking io, etc, etc.

Re: How to kill whole application if child thread raises an exception?

2016-10-26 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 10:03:30 UTC, dm wrote: Why so strange default behavior do not kill other threads in case some of threads raise exception? But thanks anyway. AFAIK, on posix you should join the child thread, and when you do, the stored exception is rethrown in the joining thr

Re: How to kill whole application if child thread raises an exception?

2016-10-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 08:42:02 UTC, dm wrote: I want to kill all my threads if it is unhandled exception. How can I do that? The spawnLinked function might help: http://dpldocs.info/experimental-docs/std.concurrency.spawnLinked.html http://dlang.org/phobos/std_concurrency.html#spaw

Re: How to kill whole application if child thread raises an exception?

2016-10-26 Thread Paolo Invernizzi via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 08:42:02 UTC, dm wrote: Hi. I tried code below: import std.concurrency; import std.stdio; void func() { throw new Exception("I'm an exception"); } void main() { auto tID = spawn(&func); foreach(line; stdin.byLine) send(tID, ""); } I expect

Re: How to kill whole application if child thread raises an exception?

2016-10-26 Thread dm via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 10:09:05 UTC, rikki cattermole wrote: If you throw an error it should crash the entire application. But really you need to set up sync points within your application to allow it to die gracefully. I tried throw new Error... But main thread still working. Tried

Re: How to kill whole application if child thread raises an exception?

2016-10-26 Thread rikki cattermole via Digitalmars-d-learn
On 26/10/2016 11:03 PM, dm wrote: On Wednesday, 26 October 2016 at 09:43:10 UTC, rikki cattermole wrote: ```D void entryPoint(alias func)() { try { func(); } catch (Exception e) { import std.stdio; writeln(e.toString()); } } void main() { auto tid = spawn

Re: How to kill whole application if child thread raises an exception?

2016-10-26 Thread dm via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 09:43:10 UTC, rikki cattermole wrote: ```D void entryPoint(alias func)() { try { func(); } catch (Exception e) { import std.stdio; writeln(e.toString()); } } void main() { auto tid =

Re: How to kill whole application if child thread raises an exception?

2016-10-26 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 09:43:10 UTC, rikki cattermole wrote: Basically when you spawn a thread giving the function, you pass it through another function which will catch any exceptions not normally caught. Of course this really should be the default behavior but somebody else may be

Re: How to kill whole application if child thread raises an exception?

2016-10-26 Thread rikki cattermole via Digitalmars-d-learn
Basically when you spawn a thread giving the function, you pass it through another function which will catch any exceptions not normally caught. Of course this really should be the default behavior but somebody else may be more of a help here. And it is pseudo code, so please don't expect it

Re: How to kill whole application if child thread raises an exception?

2016-10-26 Thread dm via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 08:53:13 UTC, rikki cattermole wrote: Simple, handle the exceptions on each thread. I don't want handle exceptions. I want my application crash with exception description. Can you change my code above to show how it can be made?

Re: How to kill whole application if child thread raises an exception?

2016-10-26 Thread rikki cattermole via Digitalmars-d-learn
On 26/10/2016 9:42 PM, dm wrote: Hi. I tried code below: import std.concurrency; import std.stdio; void func() { throw new Exception("I'm an exception"); } void main() { auto tID = spawn(&func); foreach(line; stdin.byLine) send(tID, ""); } I expect my application will die

How to kill whole application if child thread raises an exception?

2016-10-26 Thread dm via Digitalmars-d-learn
Hi. I tried code below: import std.concurrency; import std.stdio; void func() { throw new Exception("I'm an exception"); } void main() { auto tID = spawn(&func); foreach(line; stdin.byLine) send(tID, ""); } I expect my application will die immediatly, but main thread still