Timeout around function call

Imperatorn johan_forsberg_86 at hotmail.com
Tue Sep 22 21:55:51 UTC 2020

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]) and send a termination message after a specified 
time. Or you use a task and check for yourTask.done(). Or you 
could create a Thread and check isRunning.

(You didn't specify what you wanted to happen and if blocking was 
allowed or not)

More information about the Digitalmars-d-learn mailing list