Re: Timeout around function call

2020-09-27 Thread drathier via Digitalmars-d-learn
On Wednesday, 23 September 2020 at 20:58:00 UTC, Imperatorn wrote: On Wednesday, 23 September 2020 at 20:54:51 UTC, Imperatorn wrote: On Wednesday, 23 September 2020 at 20:44:51 UTC, Ali Çehreli wrote: On 9/23/20 1:19 PM, Imperatorn wrote: > [...] send a > [...] with timeout. [...] Sorry, I

Re: Timeout around function call

2020-09-23 Thread Imperatorn via Digitalmars-d-learn
On Wednesday, 23 September 2020 at 20:54:51 UTC, Imperatorn wrote: On Wednesday, 23 September 2020 at 20:44:51 UTC, Ali Çehreli wrote: On 9/23/20 1:19 PM, Imperatorn wrote: > [...] send a > [...] with timeout. [...] Sorry, I can't see the problem. Could you be more specific about what you w

Re: Timeout around function call

2020-09-23 Thread Imperatorn via Digitalmars-d-learn
On Wednesday, 23 September 2020 at 20:44:51 UTC, Ali Çehreli wrote: On 9/23/20 1:19 PM, Imperatorn wrote: > [...] send a > [...] with timeout. [...] Sorry, I can't see the problem. Could you be more specific about what you want to achieve?

Re: Timeout around function call

2020-09-23 Thread Ali Çehreli via Digitalmars-d-learn
On 9/23/20 1:19 PM, Imperatorn wrote: > No. You should not share anything. Personally I would just send a > message to request termination or use the solution provided with timeout. std.concurrency does not allow "mutable thread-local data"; so one needs to cast to shared (assuming copying is n

Re: Timeout around function call

2020-09-23 Thread Imperatorn via Digitalmars-d-learn
On Wednesday, 23 September 2020 at 17:33:50 UTC, drathier wrote: On Tuesday, 22 September 2020 at 21:55:51 UTC, Imperatorn wrote: [...] Blocking is perfectly fine. I'm wondering if I need things to be shared now or something? Not used to programming with threads. Adding a shared modifier rec

Re: Timeout around function call

2020-09-23 Thread drathier via Digitalmars-d-learn
On Tuesday, 22 September 2020 at 21:55:51 UTC, Imperatorn wrote: On Tuesday, 22 September 2020 at 09:32:13 UTC, drathier wrote: What's the obvious way to put a timeout around a function call? I'm thinking a 5 or 30 second timeout, and I'm expecting it to pretty much never time out. You have s

Re: Timeout around function call

2020-09-22 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 22 September 2020 at 09:32:13 UTC, drathier wrote: What's the obvious way to put a timeout around a function call? I'm thinking a 5 or 30 second timeout, and I'm expecting it to pretty much never time out. You have several options. Either you use the actor model (spawn[Linked]) an

Re: Timeout around function call

2020-09-22 Thread Ali Çehreli via Digitalmars-d-learn
On 9/22/20 2:32 AM, drathier wrote:> What's the obvious way to put a timeout around a function call? I'm > thinking a 5 or 30 second timeout, and I'm expecting it to pretty much > never time out. I would start a thread and use receiveTimeout(): import std.concurrency; import std.stdio; import s