Re: interrupting a function

2018-11-26 Thread Alex via Digitalmars-d-learn
On Saturday, 17 November 2018 at 08:17:36 UTC, Paul Backus wrote: You could run the calculation in another thread and use std.concurrency.receiveTimeout [1] to stop waiting for the result after a certain amount of time. Ok... would you say the following is a feasible alternative? ´´´ import s

Re: interrupting a function

2018-11-17 Thread Alex via Digitalmars-d-learn
On Saturday, 17 November 2018 at 08:17:36 UTC, Paul Backus wrote: You could run the calculation in another thread and use std.concurrency.receiveTimeout [1] to stop waiting for the result after a certain amount of time. [1] https://dlang.org/phobos/std_concurrency.html#.receiveTimeout Ah.

Re: interrupting a function

2018-11-17 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 17 November 2018 at 06:19:25 UTC, Alex wrote: It can happen, that the input params are correct, however, the calculation lasts too long. Is there a way, to measure the execution time of foo (á la benchmark) and then, if some execution time limit is exceeded to interrupt the calcula

interrupting a function

2018-11-16 Thread Alex via Digitalmars-d-learn
I wished I never come across the nightmare of such a question. And maybe, there is still a bug in my code, which I'm not aware of (which I strongly suppose :/ ). But nevertheless, and for learning purposes, assume I have something like this: ´´´ auto foo(/*input params*/) { //some long cal