How to avoid running out of OS thread handles when spawning lots of short-lived threads?

2011-06-09 Thread David Nadlinger
The title says it all – how can I avoid running out of OS thread handles when spawning lots of short-lived threads? In reality, I encountered the issue while writing tests a piece of code which spawns a thread, but this is the basic issue: --- import core.thread; void doNothing() {} void

Re: How to avoid running out of OS thread handles when spawning lots of short-lived threads?

2011-06-09 Thread Robert Clipsham
On 10/06/2011 00:17, David Nadlinger wrote: The title says it all – how can I avoid running out of OS thread handles when spawning lots of short-lived threads? In reality, I encountered the issue while writing tests a piece of code which spawns a thread, but this is the basic issue: --- import

Re: How to avoid running out of OS thread handles when spawning lots of short-lived threads?

2011-06-09 Thread David Nadlinger
On 6/10/11 1:21 AM, Robert Clipsham wrote: As far as I'm aware, you cannot avoid it, it's a hard coded limit set by the operating system. May I suggest using Fibers instead of threads? If your threads are short lived, their overhead is probably not worth it. You can also combine fibers with

Re: How to avoid running out of OS thread handles when spawning lots of short-lived threads?

2011-06-09 Thread Steven Schveighoffer
On Thu, 09 Jun 2011 19:17:28 -0400, David Nadlinger s...@klickverbot.at wrote: The title says it all – how can I avoid running out of OS thread handles when spawning lots of short-lived threads? In reality, I encountered the issue while writing tests a piece of code which spawns a

Re: How to avoid running out of OS thread handles when spawning lots of short-lived threads?

2011-06-09 Thread David Nadlinger
On 6/10/11 1:37 AM, Steven Schveighoffer wrote: t.join() ? http://www.digitalmars.com/d/2.0/phobos/core_thread.html#join Doesn't work, in my application I'm a) using std.concurrency, and b) even that is hidden behind the API I want to test. A better example would probably be the following,

Re: How to avoid running out of OS thread handles when spawning lots of short-lived threads?

2011-06-09 Thread Steven Schveighoffer
On Thu, 09 Jun 2011 19:57:27 -0400, David Nadlinger s...@klickverbot.at wrote: On 6/10/11 1:37 AM, Steven Schveighoffer wrote: t.join() ? http://www.digitalmars.com/d/2.0/phobos/core_thread.html#join Doesn't work, in my application I'm a) using std.concurrency, and b) even that is hidden