Asynchronicity in D

Jonas Drewsen jdrewsen at nospam.com
Fri Apr 1 12:59:15 PDT 2011


On 01/04/11 17.21, Sean Kelly wrote:
>
> On Apr 1, 2011, at 7:49 AM, Jonas Drewsen wrote:
>
>> On 01/04/11 01.07, dsimcha wrote:
>>>
>>>
>>> Again forgive my naiveness, as most of my experience with concurrency is
>>> concurrency to implement parallelism, not concurrency for its own sake.  Shouldn't
>>> 32,000 threads be more than enough for anything?  I can't imagine what kinds of
>>> programs would really need this level of concurrency, or how bad performance on
>>> any specific thread would be when you have this many.  Right now in my Task
>>> Manager the program with the most threads is explorer.exe, with 28.
>>
>> There doesn't have to be a thread for each socket. Actually many servers have very few threads with many sockets each. 32000 sockets is not unimaginable for certain server loads e.g. websockets or game servers. But I know it is not that common.
>
> Hopefully not at all common.  With that level of concurrency the process will spend more time context switching than executing code.

For services where clients spend most time inactive this works. An 
example could be a server for messenger like clients. Most of the time 
the clients are just connected waiting for messages. As long as nothing 
is transmitted no context switching is done.

Or maybe I've misunderstood the reason for the context switching?

/Jonas


More information about the Digitalmars-d mailing list